コード例 #1
0
 /** 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;
 }
コード例 #2
0
 /** 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();
   }
 }