XMPP In Real Time

7,785 views

Published on

This presentation gives an overview of XMPP and discusses using it in web applications.

Published in: Technology

XMPP In Real Time

  1. 1. XMPP in Real-Time Applications Ben Weaver @bwvr http://benweaver.com/
  2. 2. INTRODUCTION + What is XMPP? + Why is it “real-time”? + How does it work? + Where can you use it? + Conclusion
  3. 3. WHAT: OVERVIEW + XMPP is the Extensible Messaging and Presence Protocol + Routes messages among clients. + Broadcasts presence (status) to interested contacts. + The “X” in extensible is XML. + Since XML has namespaces... + You can invent new message types any time.
  4. 4. WHAT: HISTORY + Back in 1998... + ICQ and AOL Instant Messenger were popular IM services. + Microsoft and Yahoo! were releasing their own. + Jeremie Miller started Jabber: community driven IM + Jabber standardization began in 1999 + In 2002, an IETF working group formalized XMPP
  5. 5. WHAT: EXAMPLE <?xml version=“1.0”?> <stream to=“example.com”> <?xml version=“1.0”?> <stream from=“example.com”> <features> ... negotiate features ... <starttls /> <mechanisms /> </features> <message from=“juliet@example.com” to=“romeo@example.net”> <body>Art thou not Romeo...</body> </message> <message from=“romeo@example.net” to=“juliet@example.com”> <body>Art thou not Romeo...</body> </stream> </message> </stream> Client Server
  6. 6. WHY: AJAX + I work on web sites and applications. + AJAX is a common technique used to improve experience. + Each call is a connection + HTTP request. - This is cumbersome when making frequent requests. - (Although, some browsers support Keep-Alive). + Communication is client-driven - Servers can’t push; polling adds overhead. - Awkward for web applications.
  7. 7. WHY: BI-DIRECTIONAL + XMPP is a bi-directional stream. + XML stanzas add structure. + IQ stanzas provide REST-like semantics. + XMPP is “non-blocking”: use an event-driven style. + BOSH extends XMPP to the web.
  8. 8. HOW: OVERVIEW + XMPP comes in two parts. - Core: stream-level semantics - Jabber: use the Core for IM + XEP: make your XMPP extensions official.
  9. 9. HOW: CORE + RFC 3920 defines stream semantics. + Clients are identified as user@host/resource + <stream />: root element + <features />: bootstrap the stream - TLS: secure communication - SASL: flexible authentication + <message />: send a message + <iq id=“unique-token” type=“get|set|...” />: info query - Unique token identifies responses. - Body can be anything. + <presence />: broadcast your status
  10. 10. HOW: INSTANT MESSAGE + RFC 3921 defines how IM works with the Core. + Each account has a roster. - Track clients connected through same account. - Store contacts and permissions. + Presence - States are defined. - Notification is regulated through rosters. + Message semantics are defined.
  11. 11. HOW: EXTEND + A stream is a sequence of XML stanzas. + Invent new ones! + Submit an XMPP Extension Proposal (XEP). + Some examples: - Ping <http://xmpp.org/extensions/xep-0199.html> - Jingle <http://xmpp.org/extensions/xep-0166.html> - BOSH <http://xmpp.org/extensions/xep-0124.html>
  12. 12. WHERE: WEB SERVICE + BOSH: Bi-directional streams over Synchronous HTTP + Like Comet + Define “HTML” semantics for XMPP stream. + Example: <http://github.com/thisismedium/python-xmpp- server/blob/master/examples/_bosh.py>
  13. 13. WHERE: CHAT + Chat example + <http://github.com/thisismedium/python-xmpp-server/ blob/master/examples/chat-server.py>
  14. 14. CONCLUSION + Lot’s of people make clients; check it out! + Bi-directional + Event-driven + Works on the web
  15. 15. THE END Q&A

×