/** Delete subscriber */ public boolean deregister(Subscription sub) throws FailureException { for (Subscriber subs : subscribers) { if (subs.getSub().equals(sub)) { subscribers.remove(new Subscriber(subs.getSub(), subs.getType(), subs.getDate())); } } // System.out.println( "Agent " + buildingcs.getAID().getName() + " deregistered the agent " + sub.getMessage().getSender().getName()); return false; }
/** Notify the subscriber */ private void notify(Subscriber subscriber) { try { Subscription subscription = subscriber.getSub(); ACLMessage notification = subscription.getMessage().createReply(); notification.setPerformative(ACLMessage.INFORM); // New message // Create context SendSubscriptionMessage smsg = this.buildingcs.getNotifyMessage(subscriber); this.buildingcs.getContentManager().fillContent(notification, smsg); subscription.notify(notification); // Send message } catch (Exception e) { e.printStackTrace(); } }