RealTimeWeb with XMPP

LC
by Luis Cipriani0 views·Updated Jan 21, 2010
Powered by AI

Need to present on this topic?

Create your own polished presentation in minutes. Just describe what you need.

Free to try, no credit card required

Transcript

<stream>

<presence from=“peter@gtalk.com/home“>

<status>Watching TV...</status>

</presence>

<message from="peter@gtalk.com/home"

to="stewie@gtalk.com/work"

type="chat">

<body>How are you?</body>

</message>

<iq from="peter@gtalk.com/home"

id="rr82a1z7"

to="gtalk.com"

type="get">

<query xmlns="jabber:iq:roster"/>

</iq>

</stream>

<iq from='scoutista@zaphod/1' to='marathon-bot@zaphod/server'

id='6155:webclient' xmlns='jabber:client'>

<query xmlns='http://cipriani/game/capture'>

<event marathon='1' timestamp='1255052864229' type='action' id='1255052864229'>

<storage method='add' sync='local'/>

<team>1</team>

<action>1</action>

</event>

</query>

</iq>

<iq type='set' from='marathon-bot@zaphod'

to='pubsub.zaphod' >

<pubsub xmlns='http://jabber.org/protocol/pubsub'>

<publish node='/home/zaphod/marathon-bot/events'>

<item>

<event marathon='1'

timestamp='1255059679512'

type='action'

id='1255059679512'>

<storage method='add' sync='local'/>

<team>2</team><action>1</action>

</event>

</item>

</publish>

</pubsub>

</iq>

<message xmlns="jabber:client" from="pubsub.zaphod" to="363292661259383918570218@zaphod/1196580140125938391977300">

<event xmlns="http://jabber.org/protocol/pubsub#event">

<items node="/home/zaphod/marathon-bot/game_1">

<item id="4EB5DBCD219B5">

<event xmlns="http://cipriani/game/capture"

marathon="1"

timestamp="1259383948903"

type="action" id="1259383948903">

<storage method="add" sync="local">

<team>1</team>

<action>1</action>

</event>

</item>

</items>

</event>

</message>

<stream>

</stream>

<message from="peter@gtalk.com/home"

to="stewie@gtalk.com/work"

type="chat">

<body>How are you?</body>

</message>

<presence from=“peter@gtalk.com/home“>

<status>Watching porn...</status>

</presence>

<iq from="peter@gtalk.com/home"

id="rr82a1z7"

to="gtalk.com"

type="get">

<query xmlns="jabber:iq:roster"/>

</iq>

<stream>

</stream>

XMPP

<message from="peter@gtalk.com/home"

to="stewie@gtalk.com/work"

type="chat">

<body>How are you?</body>

</message>

<presence from=“peter@gtalk.com/home“>

<status>Watching porn...</status>

</presence>

<iq from="peter@gtalk.com/home"

id="rr82a1z7"

to="gtalk.com"

type="get">

<query xmlns="jabber:iq:roster"/>

</iq>

Luis Cipriani

<body> ...XMPP stream... </body>

XMPP

XMPP

Twitter: @lfcipriani

CLIENT

SERVER

BROWSER

lfcipriani@talleye.com

BOSH CM

SERVER

BOSH

computer science + lots of work in sw eng.

AJAX

TCP/IP

TCP/IP

COMET

HTTP

long polling

Regular XMPP connections

BOSH XMPP connections

Basketball

12 players

40 minutes

200 players

30 hours

basketball marathon

Pubsub Workflow

What happens when someone scores?

[{

"event": {

id: '12345678',

"_type": event_type,

"_timestamp": timestamp,

"team": team.id, "action": action.id,

"$team": team, "$action": action,

"body": 'um comentário',

"storage": {

_sync: 'local',

_method: 'add'

}

}

}]

SQL

_db.execute('INSERT INTO events VALUES (?, ?, ?, ?, ?, ?, ?);',

[obj["id"], obj["_type"], (obj["body"] || null), obj["_timestamp"], obj["_marathon"], (obj["team"] || null), (obj["action"] || null)]);

JSON object

<iq from='scoutista@zaphod/1' to='marathon-bot@zaphod/server'

id='6155:webclient' xmlns='jabber:client'>

<query xmlns='http://cipriani/game/capture'>

<event marathon='1' timestamp='1255052864229' type='action' id='1255052864229'>

<storage method='add' sync='local'/>

<team>1</team>

<action>1</action>

</event>

</query>

</iq>

SQL

API

[{

"event": {

id: '12345678',

"_type": event_type,

"_timestamp": timestamp,

"team": team.id, "action": action.id,

"$team": team, "$action": action,

"body": 'um comentário',

"storage": {

_sync: 'local',

_method: 'add'

}

}

}]

http://bit.ly/xmppweb

Thank you

contact:

lfcipriani@talleye.com

further reading...

  • Professional XMPP Programming with Javascript and jQuery, by Jack Moffitt

XMPP: http://www.xmpp.org

  • BOSH: http://xmpp.org/tech/bosh.shtml
  • Strophe: http://code.stanziq.com/strophe/
  • XMPP Pubsub spec: http://xmpp.org/extensions/xep-0060.html