This shows how one can use XMPP in one's Java coding to make an IM communication. It'd be really amusing to see your Facebook or Google chat in action with your own code.
1. A Beginnerâs Guide to XMPP
Soham
Sengupta
CEO, Tech IT Easy Lab of Pervasive VM Computing
+91 9830740684 (sohamsengupta@yahoo.com)
2. XMPP : what and why?
ï Existing Web Technologies have 2 broad categories
ï± Pull (Example HTTP where connection is initiated by Client and
initial communication is unidirectional (HTTP Request)
ï± Push (Where communication is initiated by clients but connection
is bi-directional, and keeps alive till disconnection or log-out )
ï Need and utility of (Server) Push:
ïŒ Real time Messaging (IM) like Google Talk, Facebook chat etc
ïŒ Delicate and urgent information like Stocks quotes that need be
initiated to clients
ïŒ Real time Location tracking
ïŒ News feeds
ïŒ Cricket scores
3. XMPP a Push Protocol
ï Extensible Messaging and Presence Protocol
In G-talk you find if the other
end is typing, entered message
or her status like busy, idle,
away etc
4. Jabber
ï Jabber may refer to:
ï The original name of the Extensible Messaging and
Presence Protocol (XMPP), the open technology for
instant messaging and presence.
ï Jabber.org, the public, free instant messaging and
presence service based on the XMPP protocol.
ï Jabber XCP, a commercial product which is an
implementation of the XMPP protocol. Acquired
by Cisco Systems in 2008.
5. Smack
1. Smack is an Open Source XMPP (Jabber) client
library for instant messaging and presence.
2. A pure Java library
3. It can be embedded into your applications to create
anything from a full XMPP client to simple XMPP
integrations such as sending notification messages
and presence-enabling devices.
4. We learn in next slides how to use Smack and
make a simple Java application client for XMPP
6. Smack: Getting started
1. Pre-requites:
a) Java SE 1.4 or above, SDK, language basics and concept
b) An active Internet connection
c) At least two Google accounts
d) The Jabber Smack API Download Site
2. Step-1
a) Have the 2 jar files,
i. Samck.jar
ii. Smackx.jar
that come with the API in your build path (CLASSPATH)
a) We make sure that the two Google id can chat with each other,
i.e. they are friend to each other
b) We make sure we are connected to Internet
7. Smack Tutorials
ï Some useful terms:
ïĄ Roster
ï¶ A list, especially of names : Dictionary meaning
ï¶ While we chat we refer to our Friends in chat list as Roster
ïŒ Connect to an XMPP Server
1. 5222: default Port for XMPP (used by most of the providers)
2. We connect to talk.google.com with our google (gmail) id and
password
8. Code Snippets to Connect
XMPPConnection ïš The Java type that represents an XMPP connection
ïŒ It needs a ConnectionConfiguration object to set up
ïŒ The configuration object needs host, port and service name
ïŒ connection.connect() connects to the server & no authentication (login) done
ïŒ connection.login(user,password) succeeds on an Active Network if user and
pasword are valid, else fails
9. Connection set up continuedâŠ
XMPP Server Port Number User ID Password
My password not
shown here
10. Send a Text Message
XMPPConnection
Text Message
Chat type
message
Recipient ID
Add text
Output console and
browser notification
12. References You can study
ï±http://www.igniterealtime.org/projects/smack/
ï±http://xmpp.org/about-xmpp/technology-overview/
ï±https://peepcode.com/products/xmpp