Reputation: 1119
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?
Upvotes: 1
Views: 614
Reputation: 10414
When your component receives <presence type='probe'/>
, it should reply with your component's current presence.
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'/>
.
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.
Upvotes: 0