Embed
Email

Programming and Extending Jabber/XMPP

Document Sample
Programming and Extending Jabber/XMPP
Shared by: HC111210143829
Categories
Tags
Stats
views:
6
posted:
12/10/2011
language:
pages:
18
Programming and Extending

Jabber/XMPP

Mrinal Kalakrishnan

PES Institute of Technology

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

Decentralization

C1 C2



S1.co

m







C7

C3 S2.net S2S

S3.org

C8

C4 C2S

C5 C9

C6

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

XML Protocol Basics

● Client to Server connection – TCP port 5222

● XML Streams

● One XML document in each direction















The Building Blocks











● Send messages from one Jabber entity to another

● Example:





Time to meet?

When do you want to meet?





● Used to indicate availability (or unavailability) of

a Jabber entity

● Example:





away

Stepped out for a while

5





● Iq = Info/Query

● Any kind of structured (XML) conversation

between two entities

● Example (logging on to the server):





myname

Home

b495d84ca048ef01508503dba94e





The Roster and Presence Subscription

● Roster (contact list) is stored on the server

● Retrieved after logging on using an query

● Adding another Jabber user to the roster is termed

“presence subscription”

● To add a user:





● Response:



More than just Instant Messaging

● Collaboration tools

● File sharing

● Gaming

● Remote systems monitoring

● Network management

● Content syndication

Jabber Code Libraries

● C ● Tcl

● C++ ● Objective-C

● Java ● PHP

● Perl ● Ruby

● Python ● Flash

● C# / .NET ● Delphi



http://www.jabber.org/developer/librarylist.php

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

, and packets

● Respond appropriately to the incoming packets in

the callback functions

● Send out , and

packets when needed

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

Webberbot

● A daemon program running as a Jabber client

● Processes incoming 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 packets.

● Ignore and packets.

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!

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!

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


Related docs
Other docs by HC111210143829
TABLE OF CONTENTS
Views: 0  |  Downloads: 0
BELGIUM
Views: 0  |  Downloads: 0
sample request referral
Views: 1  |  Downloads: 0
Spending and Output in the Short Run
Views: 2  |  Downloads: 0
Hipertensi�n arterial y embarazo
Views: 6  |  Downloads: 0
VENTA DE PARTICULARES
Views: 0  |  Downloads: 0
Grants Policy Committee
Views: 1  |  Downloads: 0
Sheet1 - La Luz Trail Run
Views: 6  |  Downloads: 0
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!