Dennis Schubert

XMPP - A little introduction

2011-09-24 software, xmpp

Recently I worked on a little project and I wanted to control a special device remotely. I am using XMPP for my daily chats and I had in my mind XMPP is extendable and so I decided to use XMPP for that.

Unfortunately my knowledge of XMPP wasn’t that huge, so I read a lot about that protocol. I ended up reading the RFCs 6120, 6121 and 6122.

I got a lot of input and I had some long telnet-sessions with my XMPP-server. ;) As I’m sure I cannot remember everything in a year, I’ll write some blogposts describing XMPP a bit.

XMPP? What is it?

XMPP is short for Extensible Messaging and Presence Protocol and that’s what it is. XMPP is a decentralized system for sending messages around the world. That’s pretty cool as you can set up your own chatting server - privacy wins. (You know, I’m one of the coders and supporters of Diaspora* - it’s decentralized, too.) All data are XML - easy to use and easy to expand.

How XMPP works

XMPP is a decentralized network. Because of that, there are Server-to-Server-connections and Server-to-Client-connection. I’ll only write about stuff regarding the Server-to-Client-connections as I don’t want to write a XMPP-server.

XMPP’s user names look like email-addresses: user1@example.com - in that example there is a user1 on example.com. user1 is able to connect with guys from other servers, so user1@example.com can chat with user2@foobar.com.

XMPP is able to handle multiple logins with the same user at the same time. So you could leave your PC logged in, take your smartphone to the balcony and continue chatting outside. The differentiation is getting done by “resources”. A resource could be “balcony”, “android”, “pc” or whatever. You cannot use a resource multiple per user, of course.

Imagine you are outside and chatting with your android. It would be nice if you can receive all the incoming stuff at your phone, your PC should continue idling around, huh? That’s why there are priorities in XMPP. It’s an interger between -128 to +127. The server should deliever the messages to the client with the highest priority.

A basic XML-snippet

Let’s take a look at a very basic thing - let’s send a message to a friend over XMPP:

<message type='chat' id='123abc123' to='user1@example.com'>
  <body>Hello my friend!</body>
</message>

That is awesome, huh? Let’s analyse it a bit. I think there’s no need to explain what the opening <message> does. But let’s have a look at its attributes:

That’s enough for a little introduction. More to come soon. Right now, I am way too busy to write further posts about XMPP. Sorry for that.

Show all posts