Programming and Extending JabberXMPP - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Programming and Extending JabberXMPP

Description:

Open XML-based protocol. Exchange messages and presence between any two ... Jabber ICQ gateway (JIT - http://jit.jabberstudio.org/) provides a bidirectional ... – PowerPoint PPT presentation

Number of Views:28
Avg rating:3.0/5.0
Slides: 19
Provided by: foss
Category:

less

Transcript and Presenter's Notes

Title: Programming and Extending JabberXMPP


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

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_at_servername.com
  • username2_at_servername.com
  • Multiple connections allowed from the same JID
  • Each connection has a unique Resource name
  • username_at_servername.com/home
  • username_at_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
  • lt?xml version1.0?gt
  • ltroottaggt
  • ltfragment1/gt
  • ltfragment2/gt
  • ltfragment3/gt
  • lt/roottaggt

6
The Building Blocks
  • ltmessage/gt
  • ltpresence/gt
  • ltiq/gt

7
ltmessage/gt
  • Send messages from one Jabber entity to another
  • Example
  • ltmessage from'me_at_myserver.com/home'
    to'you_at_yourserver.com' type'chat'gt
  • ltsubjectgtTime to meet?lt/subjectgt
  • ltbodygtWhen do you want to meet?lt/bodygt
  • lt/messagegt

8
ltpresence/gt
  • Used to indicate availability (or unavailability)
    of a Jabber entity
  • Example
  • ltpresence from'me_at_myserver.com/home'
    to'you_at_yourserver.com'gt
  • ltshowgtawaylt/showgt
  • ltstatusgtStepped out for a whilelt/statusgt
  • ltprioritygt5lt/prioritygt
  • lt/presencegt

9
ltiq/gt
  • Iq Info/Query
  • Any kind of structured (XML) conversation between
    two entities
  • Example (logging on to the server)
  • ltiq typesetgt
  • ltquery xmlnsjabberiqauthgt
  • ltusernamegtmynamelt/usernamegt
  • ltresourcegtHomelt/resourcegt
  • ltdigestgtb495d84ca048ef01508503dba94elt/digestgt
  • lt/querygt
  • lt/iqgt

10
The Roster and Presence Subscription
  • Roster (contact list) is stored on the server
  • Retrieved after logging on using an ltiq/gt query
  • Adding another Jabber user to the roster is
    termed presence subscription
  • To add a user
  • ltpresence to'you_at_yourserver.com'
    type'subscribe'gt
  • Response
  • ltpresence from'you_at_yourserver.com'
    type'subscribed'gt

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

12
Jabber Code Libraries
  • C
  • C
  • Java
  • Perl
  • Python
  • C / .NET
  • Tcl
  • Objective-C
  • PHP
  • Ruby
  • Flash
  • Delphi

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
    ltmessage/gt, ltpresence/gt and ltiq/gt packets
  • Respond appropriately to the incoming packets in
    the callback functions
  • Send out ltmessage/gt, ltpresence/gt and ltiq/gt
    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 ltpresence/gt 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 ltpresence/gt packets.
  • Ignore ltmessage/gt and ltiq/gt 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_at_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_at_mrinal.net
Write a Comment
User Comments (0)
About PowerShow.com