powered by Jive Software

Complete Procedure of Subscribing to Finese Notifications

Hi Every One,

I am new in smack and this this foum too :slight_smile: Actually, I want to subscribe for XMPP notifications. What I have done so far is:

ResourceBundle bundle = ResourceBundle.getBundle("com.ef.apps.grc.resources.config");
        String JID = bundle.getString("JABBER_ID");
        //creating Jabber ID corresponding to whcih node will be subscribed
        String myJID = userID + JID;
        final String publisherNodeID = "/finesse/api/User/" + userID + "/Dialogs";         PubSubManager mgr = new PubSubManager(connection);
        //creating node which subcribes to finesse events
        LeafNode node = (LeafNode) mgr.getNode(publisherNodeID);
        //an Item that has been, or will be published to a pubsub node.         //An Item has several properties that are dependent on the configuration of the node to which it has been or will be published.
        //Defines the listener for items being published to a node.
        node.addItemEventListener(new ItemEventCoordinator<Item>());
        node.subscribe(myJID);         //packet filter
        //Listener for Finese Notification
        PacketFilter filter = new MessageTypeFilter(Message.Type.normal);
        connection.addPacketListener(new PacketListener() {
            @Override
            public void processPacket(Packet packet) {
                //casting packet into message
                Message mes = (Message) packet;
                System.out.println("Received Event From Finesse: " + packet.toString());
                //casting message into xml containing string
                //and passing it for parsing
                // to extract caller & calle number
                XMLParser.parseXML(mes.toXML(), extension, publisherNodeID);
                System.out.println("Parsed XML: " + XMLParser.state);
                /*checking if state in                  the dialog received is equal                  to ALERTING                  then send caller and calle                  numbers to GRC*/
                if (XMLParser.state != null && XMLParser.state.equals("ALERTING")) {
                    //converting caller and calle numbers from dialog
                    //into query string                     parsedMessage = "fromAddress=" + XMLParser.fromAddress + "&toAddress=" + XMLParser.toAddress;
                } else {
                    System.out.println("State:" + XMLParser.state);
                }
            }
        }, filter);

Now, I am un-able to understand that this listener method’s will be called automatically whenever there is any notification on the node I have subscribed to ? Or I will have to run this code as servise that will continouly listen for notification on the subscribed node ?

If there is any material on web explaining the complete procedure, kindly share the link.

Thanks in Advance