Exploring XMPP

6,738 views
5,123 views

Published on

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

No Downloads
Views
Total views
6,738
On SlideShare
0
From Embeds
0
Number of Embeds
249
Actions
Shares
0
Downloads
141
Comments
0
Likes
11
Embeds 0
No embeds

No notes for slide

Exploring XMPP

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

×