XMPP-FTW
Lloyd Watkin
lloyd@evilprofessor.co.uk ::: @lloydwatkin
Quick poll
Who knows what XMPP is?
Who has used XMPP?
Who uses XMPP?
Who runs their own server?
♫
lloyd@evilprofessor.co.uk
♫
What is XMPP?
eXtensible Messaging and Presence Protocol
(aka Jabber)
Started around 1998
Became part of IETF in 2002
Think you don't use XMPP?
Google Talk
Facebook Chat
Android Intents
Whatsapp
Zoosk
Internet of things
Utility companies
Gaming applications
Many, many more places which don't advertise its usage...
What is it?
Came about in an era of closed protocol chat systems:
AIM, ICQ, Yahoo! Messenger, etc
Designed to be like the web
-
Open standard
- Federated
- Secure
- Scalable (messages are pushed)
- Decentralised
- Asynchronous
- Community
- Proven (14 years old)
Where XMPP wins
At its core very simple set of functionality:
IM and Presence
The 'X' is what makes XMPP such a a great system:
- Multi-user chat [XEP-0045]
- Publish-Subscribe [XEP-0060]
- Jingle (P2P media sessions) [XEP-0166]
People also build their own or overload existing standards e.g.
-
buddycloud
- Chesspark (uses MUC as a data transport)
Concepts
JID: Your unique identifier on the network
lloyd@evilprofessor.co.uk/mozldn
-
lloyd: Username
-
evilprofessor.co.uk: Domain
-
mozldn: Resource
A user can be logged in from multiple resources at once (phone, desktop, laptop, tablet, etc).
Each can have a priority which helps route messages to the appropriate device.
XMPP Base Messages
Messages:
<message from="lloyd@evilprofessor.co.uk/moxldn"
to="megan@evilprofessor.co.uk/home"
type="chat">
<body>I'm giving my talk at MozLdn</body>
</message>
Presence:
<presence type="dnd">
<status>Giving a talk....</status>
</presence>
IQ:
<iq to="lloyd@evilprofessor.co.uk" id="1">
<query xmlns="jabber:iq:roster" />
</iq>
...but there's a problem
XMPP *is* real-time on the web
...but its not real-time in the web-browser (yet)
People are building new silos and solving the same problems already solved with XMPP
Why?
What's wrong with XML?
- Many web developers exposure hasn't been great
- Slow in the browser
- Takes lots of code to build XML objects
The browser is all about JSON: quick, simple, fast
Web developers also want minimal APIs and fast implementation
Solutions
{"s":"<message to='alice@wonderland.lit' id='if00lu'><body>Hi you</body><body xml:lang='cy'>Prynhawn da</body><nick xmlns='http://jabber.org/protocol/nick'>Alice</nick><active xmlns='http://jabber.org/protocol/chatstates'/></message>"
}
- Write better client libraries
(open source project at CISCO, strophe.js)
-
Rewrite XMPP to use JSON natively
- throwing away lots of experience/learning/standards
- which server do you pick?
- Generic XML↔JSON schema?
- Choose a subset of XMPP which can be understood (
stanza.io)
- Something else...
XMPP-FTW
(XMPP For The Web/Win)
https://github.com/lloydwatkin/xmpp-ftw
Started coding it up at XMPP Summit Brussels January '13
Written in nodejs
Acts as a translation layer between XMPP XML and JSON for the browser
Uses named events to reduce the amount of data the browser/web developer needs to work with
What's changed?
XMPP now becomes quick, easy, fast in the browser:
Send a message
socket.emit(
'xmpp.chat.message',
{
"to": "other@example.com",
"message": "Hello world"
}
)
Receive a chat message
socket.on('xmpp.chat.message', function(data) {
console.log('Got message from ' + data.from)
console.log('Content was: ' + data.content)
})
Server adds very minimal overhead
Features
-
Login
-
Basic Presence
-
Roster
-
Chat
-
Multi-user chat (MUC XEP-0045)
-
XEP-0004 (data forms) support -- needs documenting
-
Extensible - add your own private extensions
Next steps
-
Client errors
-
Discovery (DISCO XEP-0030)
-
Rich chat messages (XEP-0071)
-
Chat status notifications (XEP-0085)
-
Implement pubsub (XEP-0060+ )
-
Add engine.io --- support older browsers too!
Try it yourself
https://xmpp-ftw.jit.su
Manual
https://xmpp-ftw.jit.su/manual
Presents all of the incoming/outgoing messages with example payloads
Demo Client
Purely javascript
Parses the manual and hooks on to incoming messages and gives autocomplete (with example payload) for outgoing messages
https://xmpp-ftw.jit.su/demo
Demo
Where it all goes horribly wrong!
Login
Set my presence
Add user to my roster
Allow them to subscribe to my presence
Chat with them
Create a MUC room
Speak in the MUC
Challenge!
Have you heard of the 15 minute CMS?
Use XMPP-FTW to build a chat client in 15 minutes...
Questions?