/** 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(); } }
/** Agree to subscribe */ private void confirm(Subscription sub) { try { ACLMessage notification = sub.getMessage().createReply(); notification.setPerformative(ACLMessage.AGREE); sub.notify(notification); // Send message // System.out.println( "Agent " + buildingcs.getAID().getName() + " sent AGREE message to the agent " + sub.getMessage().getSender().getName()); } catch (Exception e) { e.printStackTrace(); } }