|
SYS-CON.TV Webcasts
Comments
Did you read today's front page stories & breaking news?
SYS-CON.TV
|
Top Links You Must Click On
Feature Building an Instant Messaging Application Using Jabber/XMPP
An adventure with Smack and Wildfire
By: Pramod Jain; Mahaveer Jain
Jun. 23, 2006 01:15 PM
Client-Side Processing of Reply Packets
<iqProvider> The iqProvider defines the class and methods for both generating custom iq messages with the namespace jabber:iq:token for sending to server or other clients and for processing incoming iq messages with the namespace jabber:iq:token. The first section of the code is for generating an iq packet, as described in the section "Client to Server" above. The provider contains a parseIQ() method to parse the incoming message and extract useful data and the tokenNum in the reply message above and stores them in object c in Listing 2. This ends the lifecycle of the iq packet.
Use Case 2: The Custom Message
<message xmlns="" id="WHFl2-7" to="userB@sow" from="userA@sow/1139322562328"> The steps are:
Creating a Custom Message at the Client In the use case, the first step for userA to send a custom message to userB is to do the following in the client GUI: userA chooses "Open Document" from a menu or right-clicks on userB in the roster list and chooses "Open Document." The client GUI in our case uses Smack and JFace; "Open Document" triggers a call to the run() method associated with the selection. The run() method creates a message and sends to server, which it then routes to userB.
public void run() { A standard message/packet is created first; an extension is created on the message using the new SOWExtension() - this is going to carry the custom packet; the custom packet is added to the message using addExtension(icePacket). The for loop then sends the message to each selected user (userB, userC, ...). The sendPacket() method calls toXML() in Listing 3 to create an XML string. The SOWExtension class implements PacketExtension; one of the methods of interest is the class is toXML() and the class of interest is the Provider class. The Provider class provides the parse method for incoming custom messages with the extension <xsow>. The provider class will be discussed in the next section.
Processing the Custom Message at the Client
PacketListener listener = new PacketListener() { The message extension and the SOWExtension's Provider are defined in smack.provider.
<extensionProvider> Note: iqProvider to handle custom IQ messages was defined in reply packets code above. extensionProvider to handle custom message extension is defined in the code immediately above.
Summary Some of the specific uses of the <iq> extension will be to create rich IM applications that interact with a backend application server and/or database; examples of uses of the <message> extension include doing things like opening browsers and sending files from one user's client IM application to another. References
We would like to acknowledge partial funding from NIMH of NIH, and the help of Gaurav Mantro for coding some pieces of the client application and thank Ryan Graham, Gaston Dombiak, and a few others for answering questions we posted on www.jivesoftware.org's discussion forum for developers. Reader Feedback: Page 1 of 1
Your Feedback
Enterprise Open Source Magazine Latest Stories . . .
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||