Your SlideShare is downloading. ×
0
<exploring:xmpp/>
            Jack Moffitt
Why XMPP?
HTTP APIs are great
HTTP polling sucks
Real time is different
XMPP is real time
XMPP basics
XMPP network
XMPP addressing
example.com
jack@example.com
jack@example.com/home
jack@example.com/work
jack@example.com/7a29d835f9c
XMPP protocol
XML
XML streams
XML stanzas
<message/>
<presence/>
<iq/>
<message/>
<message
    from=’juliet@sapo.pt/home’
    to=’romeo@sapo.pt’
    type=’chat’>
 <body>
  Wherefore art thou, Romeo?
 </bo...
<message
    from=’juliet@sapo.pt/home’
    to=’romeo@sapo.pt’
    type=’chat’>
 <body>
  Wherefore art thou, Romeo?
 </bo...
<message
    from=’juliet@sapo.pt/home’
    to=’romeo@sapo.pt’
    type=’chat’>
 <body>
  Wherefore art thou, Romeo?
 </bo...
<message
    from=’juliet@sapo.pt/home’
    to=’romeo@sapo.pt’
    type=’chat’>
 <body>
  Wherefore art thou, Romeo?
 </bo...
<message
   from=’juliet@sapo.pt/home’
   to=’romeo@sapo.pt’
   type=’chat’>
 <body>
  Wherefore art thou, Romeo?
 </body>...
<presence/>
<presence>
 <show>away</show>
 <status>At Codebits</status>
</presence>
<presence
    type=’available’>
 <show>away</show>
 <status>At Codebits</status>
</presence>
<presence
    type=’available’>
 <show>away</show>
 <status>At Codebits</status>
</presence>
<presence
    type=’available’>
 <show>away</show>
 <status>At Codebits</status>
</presence>
<iq/>
<iq
    to=’sapo.pt’
    type=’get’
    id=’disco:1’>
 <query xmlns=’disco#info’/>
</iq>
<iq
    to=’sapo.pt’
    type=’get’
    id=’disco:1’>
 <query xmlns=’disco#info’/>
</iq>
<iq
    to=’sapo.pt’
    type=’get’
    id=’disco:1’>
 <query xmlns=’disco#info’/>
</iq>
<iq
    to=’sapo.pt’
    type=’get’
    id=’disco:1’>
 <query xmlns=’disco#info’/>
</iq>
<iq
    to=’sapo.pt’
    type=’get’
    id=’disco:1’>
 <query xmlns=’disco#info’/>
</iq>
<iq
    to=’romeo@sapo.pt/home’
    from=’sapo.pt’
    type=’result’
    id=’disco:1’>
 <query xmlns=’disco#info’>
   <ide...
<iq
    to=’romeo@sapo.pt/home’
    from=’sapo.pt’
    type=’result’
    id=’disco:1’>
 <query xmlns=’disco#info’>
   <ide...
<iq
    to=’romeo@sapo.pt/home’
    from=’sapo.pt’
    type=’result’
    id=’disco:1’>
 <query xmlns=’disco#info’>
   <ide...
<iq
    to=’romeo@sapo.pt/home’
    from=’sapo.pt’
    type=’result’
    id=’disco:1’>
 <query xmlns=’disco#info’>
   <ide...
The application
example
contrived
Server monitoring
Goodbye SNMP
XMPP APIs
Features
Collection hub
Collectors are XMPP bots
Controlled via client
Presence
Discovery
Commands
Notification
No processing
Presence
Communicates status
Subscribing
<presence
  type=’subscribe’
  to=’xmpp@mon.sapo.pt’/>
<presence
  type=’subscribed’
  from=’xmpp@mon...’
  to=’client@mon...’/>
Rosters
<iq
   type=’get’
   id=’roster1’>
 <query
     xmlns=’jabber:iq:roster’/>
</iq>
<iq
   type=’result’
   id=’roster1’>
 <query
     xmlns=’jabber:iq:roster’>
   <item
      jid=’xmpp@mon...’
      subscr...
Initial presence
<presence/>
Starting up
<presence
  from=’xmpp@mon...’/>
Dead server
<presence
  type=’unavailable’
  from=’xmpp@mon...’/>
Busy server
<presence
  type=’available’>
 <show>away</show>
 <status>
  Overloaded. Can’t take
  more jobs.
 </status>
</presence>
Discovery
Meta information
Disco info
<iq
   id=’disco1’
   type=’get’
   to=’xmpp@mon...’>
 <query
     xmlns=’.../disco#info’/>
</iq>
<iq ...>
 <query
    xmlns=’.../disco#info’>
   <identity
       name=’XMPP Monitor’
       category=’monitor’
       type...
Statistics available
Disco items
<iq
   id=’disco2’
   type=’get’
   to=’xmpp@mon...’>
 <query
     xmlns=’.../disco#items’/>
</iq>
<iq ...>
 <query xmlns=’.../disco#items’>
   <item
       name=’CPU Load’
       jid=’xmpp@mon...’
       node=’cpu’/>
   ...
<iq ...>
 <query xmlns=’.../disco#items’>
   <item
       name=’CPU Load’
       jid=’xmpp@mon...’
       node=’cpu’/>
   ...
<iq ...>
 <query xmlns=’.../disco#items’>
   <item
       name=’CPU Load’
       jid=’xmpp@mon...’
       node=’cpu’/>
   ...
Gathering statistics
Disco info again
With a node
<iq
   id=’disco3’
   type=’get’
   to=’xmpp@mon...’>
 <query
     xmlns=’.../disco#info’
     node=’cpu’/>
</iq>
<iq ...>
 <query xmlns=’.../disco#info’
    node=’cpu’>
   <statisic
       xmlns=’codebits’
       name=’5-min’
       va...
<statistic/>
Extended stanza
Create your own
Namespace
<iq ...>
 <query xmlns=’.../disco#info’
    node=’cpu’>
   <statisic
       xmlns=’codebits’
       name=’5-min’
       va...
Commands
Ad-hoc commands
RPC
Input and output
Data forms
<x xmlns='jabber:x:data' type='...'>
 <field type='hidden'
    var='FORM_TYPE'>
  <value>jabber:bot</value>
 </field>
 <field...
<x xmlns='jabber:x:data' type='...'>
 <field type='hidden'
    var='FORM_TYPE'>
  <value>jabber:bot</value>
 </field>
 <field...
<x xmlns='jabber:x:data' type='...'>
 <field type='hidden'
    var='FORM_TYPE'>
  <value>jabber:bot</value>
 </field>
 <field...
<x xmlns='jabber:x:data' type='...'>
 <field type='hidden'
    var='FORM_TYPE'>
   <value>jabber:bot</value>
 </field>
 <fiel...
<x xmlns='jabber:x:data' type='...'>
 <field type='hidden'
    var='FORM_TYPE'>
  <value>jabber:bot</value>
 </field>
 <field...
Reboot command
<iq ...>
 <command
    xmlns=’.../commands’
    node=’reboot’
    action=’execute’/>
</iq>
<iq ...>
 <command
    xmlns=’.../commands’
     node=’reboot’
    action=’execute’/>
</iq>
<iq ...>
 <command
    xmlns=’.../commands’
    node=’reboot’
    action=’execute’/>
</iq>
<iq ...>
 <command
    xmlns=’.../commands’
    node=’reboot’
    status=’completed’/>
</iq>
Stats reset
Shell commands
Notifications
Important events
Limits exceeded
Publish subscribe
Pubsub
Nodes
Node hierarchy
Leaves
Collections
Bots publish
Client subscribes
PEP
Personal eventing protocol
Profile of pubsub
Simple
Presence
Every JID is a pubsub node
Subscriptions are automatic
Publishing
<iq ...>
 <pubsub xmlns=’.../pubsub’>
   <publish node=’codebits’>
    <item>
       <rebooted
         xmlns=’codebits’/>...
<iq ...>
 <pubsub xmlns=’.../pubsub’>
   <publish node=’codebits’>
    <item>
       <rebooted
         xmlns=’codebits’/>...
<iq ...>
 <pubsub xmlns=’.../pubsub’>
   <publish node=’codebits’>
    <item>
       <rebooted
         xmlns=’codebits’/>...
<iq ...>
 <pubsub xmlns=’.../pubsub’>
   <publish node=’codebits’>
    <item>
       <rebooted
         xmlns=’codebits’/>...
<iq ...>
 <pubsub xmlns=’.../pubsub’>
   <publish node=’codebits’>
    <item>
       <rebooted
         xmlns=’codebits’/>...
Subscribing
Automatic
Entity capabilities
Caps
Caps extend presence
<presence>
 <c
    xmlns=’.../caps’
    node=’codebits’
    hash=’sha-1’
    ver=’...hash...’/>
</presence>
<presence>
 <c
    xmlns=’.../caps’
    node=’codebits’
    hash=’sha-1’
    ver=’...hash...’/>
</presence>
<presence>
 <c
    xmlns=’.../caps’
    node=’codebits’
    hash=’sha-1’
    ver=’...hash...’/>
</presence>
Interpreted via disco
<feature var=’codebits’/>
<feature var=’codebits+notify’/>
Events
<message ...>
 <event xmlns=’.../pubsub’>
  <items node=’codebits’>
    <item>
     <rebooted xmlns=’codebits’/>
    </ite...
Just add code
http://www.xmpp.org

 http://metajack.im

 jack@metajack.im
Exploring XMPP
Exploring XMPP
Exploring XMPP
Exploring XMPP
Upcoming SlideShare
Loading in...5
×

Exploring XMPP

4,390

Published on

0 Comments
11 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,390
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
139
Comments
0
Likes
11
Embeds 0
No embeds

No notes for slide

Transcript of "Exploring XMPP"

  1. 1. <exploring:xmpp/> Jack Moffitt
  2. 2. Why XMPP?
  3. 3. HTTP APIs are great
  4. 4. HTTP polling sucks
  5. 5. Real time is different
  6. 6. XMPP is real time
  7. 7. XMPP basics
  8. 8. XMPP network
  9. 9. XMPP addressing
  10. 10. example.com
  11. 11. jack@example.com
  12. 12. jack@example.com/home
  13. 13. jack@example.com/work
  14. 14. jack@example.com/7a29d835f9c
  15. 15. XMPP protocol
  16. 16. XML
  17. 17. XML streams
  18. 18. XML stanzas
  19. 19. <message/>
  20. 20. <presence/>
  21. 21. <iq/>
  22. 22. <message/>
  23. 23. <message from=’juliet@sapo.pt/home’ to=’romeo@sapo.pt’ type=’chat’> <body> Wherefore art thou, Romeo? </body> </message>
  24. 24. <message from=’juliet@sapo.pt/home’ to=’romeo@sapo.pt’ type=’chat’> <body> Wherefore art thou, Romeo? </body> </message>
  25. 25. <message from=’juliet@sapo.pt/home’ to=’romeo@sapo.pt’ type=’chat’> <body> Wherefore art thou, Romeo? </body> </message>
  26. 26. <message from=’juliet@sapo.pt/home’ to=’romeo@sapo.pt’ type=’chat’> <body> Wherefore art thou, Romeo? </body> </message>
  27. 27. <message from=’juliet@sapo.pt/home’ to=’romeo@sapo.pt’ type=’chat’> <body> Wherefore art thou, Romeo? </body> </message>
  28. 28. <presence/>
  29. 29. <presence> <show>away</show> <status>At Codebits</status> </presence>
  30. 30. <presence type=’available’> <show>away</show> <status>At Codebits</status> </presence>
  31. 31. <presence type=’available’> <show>away</show> <status>At Codebits</status> </presence>
  32. 32. <presence type=’available’> <show>away</show> <status>At Codebits</status> </presence>
  33. 33. <iq/>
  34. 34. <iq to=’sapo.pt’ type=’get’ id=’disco:1’> <query xmlns=’disco#info’/> </iq>
  35. 35. <iq to=’sapo.pt’ type=’get’ id=’disco:1’> <query xmlns=’disco#info’/> </iq>
  36. 36. <iq to=’sapo.pt’ type=’get’ id=’disco:1’> <query xmlns=’disco#info’/> </iq>
  37. 37. <iq to=’sapo.pt’ type=’get’ id=’disco:1’> <query xmlns=’disco#info’/> </iq>
  38. 38. <iq to=’sapo.pt’ type=’get’ id=’disco:1’> <query xmlns=’disco#info’/> </iq>
  39. 39. <iq to=’romeo@sapo.pt/home’ from=’sapo.pt’ type=’result’ id=’disco:1’> <query xmlns=’disco#info’> <identity category='server' type='im' name='ejabberd'/> <feature var='vcard-temp'/> </query> </iq>
  40. 40. <iq to=’romeo@sapo.pt/home’ from=’sapo.pt’ type=’result’ id=’disco:1’> <query xmlns=’disco#info’> <identity category='server' type='im' name='ejabberd'/> <feature var='vcard-temp'/> </query> </iq>
  41. 41. <iq to=’romeo@sapo.pt/home’ from=’sapo.pt’ type=’result’ id=’disco:1’> <query xmlns=’disco#info’> <identity category='server' type='im' name='ejabberd'/> <feature var='vcard-temp'/> </query> </iq>
  42. 42. <iq to=’romeo@sapo.pt/home’ from=’sapo.pt’ type=’result’ id=’disco:1’> <query xmlns=’disco#info’> <identity category='server' type='im' name='ejabberd'/> <feature var='vcard-temp'/> </query> </iq>
  43. 43. The application
  44. 44. example
  45. 45. contrived
  46. 46. Server monitoring
  47. 47. Goodbye SNMP
  48. 48. XMPP APIs
  49. 49. Features
  50. 50. Collection hub
  51. 51. Collectors are XMPP bots
  52. 52. Controlled via client
  53. 53. Presence
  54. 54. Discovery
  55. 55. Commands
  56. 56. Notification
  57. 57. No processing
  58. 58. Presence
  59. 59. Communicates status
  60. 60. Subscribing
  61. 61. <presence type=’subscribe’ to=’xmpp@mon.sapo.pt’/>
  62. 62. <presence type=’subscribed’ from=’xmpp@mon...’ to=’client@mon...’/>
  63. 63. Rosters
  64. 64. <iq type=’get’ id=’roster1’> <query xmlns=’jabber:iq:roster’/> </iq>
  65. 65. <iq type=’result’ id=’roster1’> <query xmlns=’jabber:iq:roster’> <item jid=’xmpp@mon...’ subscription=’to’/> </query> </iq>
  66. 66. Initial presence
  67. 67. <presence/>
  68. 68. Starting up
  69. 69. <presence from=’xmpp@mon...’/>
  70. 70. Dead server
  71. 71. <presence type=’unavailable’ from=’xmpp@mon...’/>
  72. 72. Busy server
  73. 73. <presence type=’available’> <show>away</show> <status> Overloaded. Can’t take more jobs. </status> </presence>
  74. 74. Discovery
  75. 75. Meta information
  76. 76. Disco info
  77. 77. <iq id=’disco1’ type=’get’ to=’xmpp@mon...’> <query xmlns=’.../disco#info’/> </iq>
  78. 78. <iq ...> <query xmlns=’.../disco#info’> <identity name=’XMPP Monitor’ category=’monitor’ type=’server’/> </query> </iq>
  79. 79. Statistics available
  80. 80. Disco items
  81. 81. <iq id=’disco2’ type=’get’ to=’xmpp@mon...’> <query xmlns=’.../disco#items’/> </iq>
  82. 82. <iq ...> <query xmlns=’.../disco#items’> <item name=’CPU Load’ jid=’xmpp@mon...’ node=’cpu’/> ... </query> </iq>
  83. 83. <iq ...> <query xmlns=’.../disco#items’> <item name=’CPU Load’ jid=’xmpp@mon...’ node=’cpu’/> ... </query> </iq>
  84. 84. <iq ...> <query xmlns=’.../disco#items’> <item name=’CPU Load’ jid=’xmpp@mon...’ node=’cpu’/> ... </query> </iq>
  85. 85. Gathering statistics
  86. 86. Disco info again
  87. 87. With a node
  88. 88. <iq id=’disco3’ type=’get’ to=’xmpp@mon...’> <query xmlns=’.../disco#info’ node=’cpu’/> </iq>
  89. 89. <iq ...> <query xmlns=’.../disco#info’ node=’cpu’> <statisic xmlns=’codebits’ name=’5-min’ value=’0.4’/> </query> </iq>
  90. 90. <statistic/>
  91. 91. Extended stanza
  92. 92. Create your own
  93. 93. Namespace
  94. 94. <iq ...> <query xmlns=’.../disco#info’ node=’cpu’> <statisic xmlns=’codebits’ name=’5-min’ value=’0.4’/> </query> </iq>
  95. 95. Commands
  96. 96. Ad-hoc commands
  97. 97. RPC
  98. 98. Input and output
  99. 99. Data forms
  100. 100. <x xmlns='jabber:x:data' type='...'> <field type='hidden' var='FORM_TYPE'> <value>jabber:bot</value> </field> <field type='text-single' var='botname'> <value>Awesome Bot</value> </field> </x>
  101. 101. <x xmlns='jabber:x:data' type='...'> <field type='hidden' var='FORM_TYPE'> <value>jabber:bot</value> </field> <field type='text-single' var='botname'> <value>Awesome Bot</value> </field> </x>
  102. 102. <x xmlns='jabber:x:data' type='...'> <field type='hidden' var='FORM_TYPE'> <value>jabber:bot</value> </field> <field type='text-single' var='botname'> <value>Awesome Bot</value> </field> </x>
  103. 103. <x xmlns='jabber:x:data' type='...'> <field type='hidden' var='FORM_TYPE'> <value>jabber:bot</value> </field> <field type='text-single' var='botname'> <value>Awesome Bot</value> </field> </x>
  104. 104. <x xmlns='jabber:x:data' type='...'> <field type='hidden' var='FORM_TYPE'> <value>jabber:bot</value> </field> <field type='text-single' var='botname'> <value>Awesome Bot</value> </field> </x>
  105. 105. Reboot command
  106. 106. <iq ...> <command xmlns=’.../commands’ node=’reboot’ action=’execute’/> </iq>
  107. 107. <iq ...> <command xmlns=’.../commands’ node=’reboot’ action=’execute’/> </iq>
  108. 108. <iq ...> <command xmlns=’.../commands’ node=’reboot’ action=’execute’/> </iq>
  109. 109. <iq ...> <command xmlns=’.../commands’ node=’reboot’ status=’completed’/> </iq>
  110. 110. Stats reset
  111. 111. Shell commands
  112. 112. Notifications
  113. 113. Important events
  114. 114. Limits exceeded
  115. 115. Publish subscribe
  116. 116. Pubsub
  117. 117. Nodes
  118. 118. Node hierarchy
  119. 119. Leaves
  120. 120. Collections
  121. 121. Bots publish
  122. 122. Client subscribes
  123. 123. PEP
  124. 124. Personal eventing protocol
  125. 125. Profile of pubsub
  126. 126. Simple
  127. 127. Presence
  128. 128. Every JID is a pubsub node
  129. 129. Subscriptions are automatic
  130. 130. Publishing
  131. 131. <iq ...> <pubsub xmlns=’.../pubsub’> <publish node=’codebits’> <item> <rebooted xmlns=’codebits’/> </item> </publish> </pubsub> </iq>
  132. 132. <iq ...> <pubsub xmlns=’.../pubsub’> <publish node=’codebits’> <item> <rebooted xmlns=’codebits’/> </item> </publish> </pubsub> </iq>
  133. 133. <iq ...> <pubsub xmlns=’.../pubsub’> <publish node=’codebits’> <item> <rebooted xmlns=’codebits’/> </item> </publish> </pubsub> </iq>
  134. 134. <iq ...> <pubsub xmlns=’.../pubsub’> <publish node=’codebits’> <item> <rebooted xmlns=’codebits’/> </item> </publish> </pubsub> </iq>
  135. 135. <iq ...> <pubsub xmlns=’.../pubsub’> <publish node=’codebits’> <item> <rebooted xmlns=’codebits’/> </item> </publish> </pubsub> </iq>
  136. 136. Subscribing
  137. 137. Automatic
  138. 138. Entity capabilities
  139. 139. Caps
  140. 140. Caps extend presence
  141. 141. <presence> <c xmlns=’.../caps’ node=’codebits’ hash=’sha-1’ ver=’...hash...’/> </presence>
  142. 142. <presence> <c xmlns=’.../caps’ node=’codebits’ hash=’sha-1’ ver=’...hash...’/> </presence>
  143. 143. <presence> <c xmlns=’.../caps’ node=’codebits’ hash=’sha-1’ ver=’...hash...’/> </presence>
  144. 144. Interpreted via disco
  145. 145. <feature var=’codebits’/> <feature var=’codebits+notify’/>
  146. 146. Events
  147. 147. <message ...> <event xmlns=’.../pubsub’> <items node=’codebits’> <item> <rebooted xmlns=’codebits’/> </item> </items> </event> </message>
  148. 148. Just add code
  149. 149. http://www.xmpp.org http://metajack.im jack@metajack.im
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×