Title: Instant Messaging with XMPP AKA Jabber
1Instant Messaging with XMPP(AKA Jabber)
Jason Wambach 2005 Harpoon Technologies
2Why use instant messaging?
- User Communication
- Application Monitoring
- Application Control
- Presence Notification
3Why XMPP?
- Open Protocol
- Well Documented
- Extensible (Extensible Messaging and Presence
Protocol) - - See Jeps (Jabber enhancement Proposal) at
www.jabber.org/jeps/ - IETF Standardized
4Servers
- Commercial
- - Merak, Jabber XCP, Soapbox, Sun
- Free (fuhree?!)
- - Jive, Jabberd, OpenIM, Chime, etc.
- - GPL, BSD Licenses
- - Some available as dual license (Jive)
- Pre Existing
- - Google (talk.google.com)
5Clients
- Many pre-existing GUI based clients
- Google Talk, Trillian Pro, Gaim, etc.
- APIs
- Smack (Java)
- Jabber-Net (C .Net)
- Jabber4R (Ruby)
- Jabber.py (Python)
- Others (C, Perl, Flash, etc)
6Example using Smack
7Client Connection
import org.jivesoftware.smack. XMPPConnection
con new XMPPConnection(host, port,
service) con.login(user, password)
-Will work through firewalls given a proxy route
and proper jvm settings -Usernames may or may not
contain host/resource information (ex.
user_at_host.com/resource) -Service is optional on
most servers (Not Google!) -port default is 5222
8Sending Messages
- public void sendMessage(String user, String
message) throws XMPPException -
- Chat chat getChat(user)
- if (chat null)
-
- chat con.createChat(user)
- addChat(chat, user)
-
- chat.sendMessage(message)
-Using a map to keep track of Chats -Fire and
forget
9Receiving Messages
- PacketFilter filter new PacketTypeFilter(Message
.class) - //Synchronous
- PacketCollector myCollector con.createPacketColl
ector(filter) - PacketListener myListener new PacketListener()
- public void processPacket(Packet packet)
- //do something
-
-
- //Asynchronus
- con.addPacketListener(myListener, filter)
- ...
- myCollector.pollResult() //check if any
messages
-Allows Asynchronus (event driven) and
Synchronous access (Polling) -Filters set for
various packets -Many types of packets (Message,
Auth, Roster, Presence, etc)
10Rosters
- public void addUserToRoster(String user) throws
XMPPException - if (!isUserOnRoster(user))
- Roster roster con.getRoster()
- if (roster ! null)
- roster.createEntry(user, user, null)
-
-
-
- public boolean isUserOnRoster(String user)
- Roster roster con.getRoster()
- if (roster ! null)
- return roster.contains(user)
-
- return false
-
- public boolean isUserOnline(String user)
- Roster roster con.getRoster()
- if (roster ! null roster.getPresence(user)
! null) - return true
-Rosters and presence use permissions which must
be granted. (Auto or Manually). -Roster polling
not necessarily required to check presence, can
use roster listeners. -Presence is generally tied
to roster entries, although not required.
11Server Setup
- Jive
- Easy setup on Linux/Windows
- Embedded or External Database (MySql)
- Web based Administration
- Google
- No need to setup anything to get started
- Latest Smack API has helper classes for google.
12Considerations
- Not a silver bullet
- Not a replacement for a message queue system.
(Guaranteed delivery, delivery notification, etc) - Not all servers support every feature
- No server supports all features. (Voice, Server
to Server connections, Querying, Clustering, etc) - Some servers are more flexible than others
(Integration with LDAP, etc) - XML Overhead
13Current XMPP Projects
- eBay notices
- Monitor auctions actively.
- Add/Remove custom auction searches.
- Not exactly within eBays use policy.
- Remote Appliance Monitoring
- Use javacomm to monitor aquarium heaters
- Notification of temp states/on-off, etc.
- Lighting Control
- Integrated with X10 to control home lighting/fans.
14Questions?
15Resources
- Jive Software - www.jivesoftware.org (Server,
Smack API) - Jabber Foundation - www.jabber.org
- Lists of Commercial and Open Source Servers
- Lists of Various APIs
- Lists of Various Clients
- JEP Listings
- XMPP Community Pages - www.xmpp.org
- Internet Engineering Task Force www.ietf.org
- RFC 3920 (XMPP Core)
- RFC 3921 (XMPP Messaging and Presence)
- Contact Me jwambach_at_harpoontech.com