xmpp - How to join multiple rooms by just sending one <presence> message to ejabberd server -


for example, have 20 rooms join. simple solution send 20 message each room id. considering performance, bad.

i want join 20 rooms sending 1 <presence> message, how achieve this? writing module hook custom <presence> message? not know how write kind of module.

in xep-0045 multi user chat, there no way defined join 20 chat rooms single presence packet.

however, combining other xmpp extension multi user chat, can achieve in pure xmpp, without need write custom ejabberd extensions.

you can rely on xep-0033 extended stanza addressing, can send xmpp packet several recipient. works presence shown in example.

ejabberd configuration

xep-0033 extending stanza addressing supported default since ejabberd 15.04. make sure have enable feature adding mod_multicast in ejabberd configuration modules section:

modules: ...   mod_multicast: {} 

when service enabled, should have new service (as default named multicast.example.net) on server supporting feature http://jabber.org/protocol/address:

<iq type='get'     to='multicast.example.net'     id='info1'>   <query xmlns='http://jabber.org/protocol/disco#info'/> </iq> 

and response is:

<iq from="multicast.example.net" type="result" to="test@example.net/laptop" id="info1"> <query xmlns="http://jabber.org/protocol/disco#info"> <identity category="service" type="multicast" name="multicast"/> <feature var="http://jabber.org/protocol/disco#info"/> <feature var="http://jabber.org/protocol/disco#items"/> <feature var="vcard-temp"/> <feature var="http://jabber.org/protocol/address"/> </query> </iq> 

usage

once enabled, easy send presence packet targeting several muc rooms:

<presence to='multicast.example.net'>     <addresses xmlns='http://jabber.org/protocol/address'>         <address type='bcc' jid='testroom@conference.example.net/usernick'/>         <address type='bcc' jid='testroom2@ conference.example.net/usernick'/>     </addresses> </presence> 

you see joining several rooms @ same time.

issues

xep-0033 did not mention use case , module had not been testing join multiple rooms. while writing example found when disconnecting, user not leave rooms had joined. means have wait following github issue fixed before feature usable in production: broadcast presence change after multicast presence packet.


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -