1 / 18

Programming and Extending Jabber/XMPP

Mrinal Kalakrishnan PES Institute of Technology. Programming and Extending Jabber/XMPP. Jabber and XMPP. Open XML-based protocol Exchange messages and presence between any two points on the internet Instant messaging, and much more Decentralized – like email

tarika
Download Presentation

Programming and Extending Jabber/XMPP

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Mrinal Kalakrishnan PES Institute of Technology Programming and Extending Jabber/XMPP

  2. Jabber and XMPP • Open XML-based protocol • Exchange messages and presence between any two points on the internet • Instant messaging, and much more • Decentralized – like email • XMPP = eXtensible Messaging and Presence Protocol, standardized by the IETF

  3. Decentralization C1 C2 S1.com C7 S2.net S3.org C3 S2S C8 C4 C2S C5 C9 C6

  4. JIDs, Resources, Priorities • JID – Jabber ID • username@servername.com • username2@servername.com • Multiple connections allowed from the same JID • Each connection has a unique “Resource” name • username@servername.com/home • username@servername.com/work • Each connection/resource also has a priority • Higher priority resource gets all messages

  5. XML Protocol Basics • Client to Server connection – TCP port 5222 • XML Streams • One XML document in each direction <?xml version=”1.0”?> <roottag> <fragment1/> <fragment2/> <fragment3/> </roottag>

  6. The Building Blocks • <message/> • <presence/> • <iq/>

  7. <message/> • Send messages from one Jabber entity to another • Example: <message from='me@myserver.com/home' to='you@yourserver.com' type='chat'> <subject>Time to meet?</subject> <body>When do you want to meet?</body> </message>

  8. <presence/> • Used to indicate availability (or unavailability) of a Jabber entity • Example: <presence from='me@myserver.com/home' to='you@yourserver.com'> <show>away</show> <status>Stepped out for a while</status> <priority>5</priority> </presence>

  9. <iq/> • Iq = Info/Query • Any kind of structured (XML) conversation between two entities • Example (logging on to the server): <iq type=”set”> <query xmlns=”jabber:iq:auth”> <username>myname</username> <resource>Home</resource> <digest>b495d84ca048ef01508503dba94e</digest> </query> </iq>

  10. The Roster and Presence Subscription • Roster (contact list) is stored on the server • Retrieved after logging on using an <iq/> query • Adding another Jabber user to the roster is termed “presence subscription” • To add a user: <presence to='you@yourserver.com' type='subscribe'> • Response: <presence from='you@yourserver.com' type='subscribed'>

  11. More than just Instant Messaging • Collaboration tools • File sharing • Gaming • Remote systems monitoring • Network management • Content syndication

  12. Tcl Objective-C PHP Ruby Flash Delphi Jabber Code Libraries • C • C++ • Java • Perl • Python • C# / .NET http://www.jabber.org/developer/librarylist.php

  13. Basic Jabber Application Programming • Connect to port 5222 of the server • Open XML stream, and authenticate with the server • Send initial presence, and request roster • Register callback functions for incoming <message/>, <presence/> and <iq/> packets • Respond appropriately to the incoming packets in the callback functions • Send out <message/>, <presence/> and <iq/> packets when needed

  14. Example Application – Webber • A Jabber presence indicator for a webpage • Uses the jabber.py Python library • Implementation consists of two distinct sections: • A 'bot' program continuously running as a Jabber client, gathering presence information and updating a database • The webpage, a PHP script which reads the database and displays the presence status

  15. Webberbot • A daemon program running as a Jabber client • Processes incoming <presence/> packets: • If presence type is “available” or “unavailable”, update the presence information in a table with the full JID as the key • If presence type is “subscribe” or “unsubscribe”, send the appropriate reply <presence/> packets. • Ignore <message/> and <iq/> packets.

  16. Webber: The PHP Script • Read the presence entries from the database • If there are multiple resources listed for the same JID, return the status of the highest priority • Display the status on the page!

  17. Example 2 – SMS Interfacing • Jabber ICQ gateway (JIT - http://jit.jabberstudio.org/) provides a bidirectional interface between Jabber and SMS • Build a client that responds to message events from the JID of the mobile phone (eg: 919845012345@sms.myjabberserver.com) and performs actions based on the message contents • Simple to program, and the possibilities are endless!

  18. Resources and URLs • http://www.jabber.org/ - Home of the Jabber Software Foundation • http://www.jabberstudio.org/ - Development hub for the Jabber community • http://mrinal.net/webber/ - The example application Contact me at mail@mrinal.net

More Related