1
votes

I have just discovered how awesome XMPP is and I am experimenting with developing multiplayer games as XMPP components (XEP-0114).

However, I am having trouble with indicating presence for the component. Is it true, that the component will need to respond to <presence> stanzas itself?

Sure it can do that, but not if it is down for maintenance. Also, who does the component notify when it is back up? It could of course register all interested users in a database, but if it is down for five minutes, then that list surely will have changed. Users that were not previously interested will be now, and users who were interested won't be any more.

Also, if it crashes (could happen), it cannot send out 'unavailable' presence indications.

Can't this work somehow be offloaded to the server?

1
What programming language? What XMPP library?Joe Hildebrand
I use JavaScript with node-xmpp. However this should be protocol, not specific to implementation...unless I have misunderstood something.Robert Larsen
You're correct, except that in certain environments (like SleekXMPP), there is an existing class to handle the protocol for you, which would have been a shortcut.Joe Hildebrand

1 Answers

0
votes
  1. When your component receives <presence type='probe'/>, it should reply with your component's current presence.

  2. When your component receives <presence type='subscribe'/>, it should save the from address in a some sort of storage mechanism, then reply with <presence type='subscribed'/>.

  3. When your component comes online, it should send presence to each of the subscribers saved in step 2.

Always make sure to put both a to address and a from address on all stanzas sent by your component. If you are used to writing clients, you're likely to forget that in step 3.