Thursday 19 July 2012

XMPP Chat room mechanism # Part-1

XMPP protocol provides specification for multi-user chatting(MUC). It is about service provider to implement it. You need to enable MUC from server side. Provider would also give facility to create persistent chat rooms. In terms of XMPP, chat room is known as conference. User can also create a new conference from client program.

When user is loggin in, he needs to ask for available service on server side. User need to send following XML to server.

<iq type='get' from='{user-jid/resource}' to='domain' id='discoitem1'>
<query xmlns='http://jabber.org/protocol/disco#items'/>
</iq>

Server will send back all available services. Services will be sent as XML items. Each item contains service name and service JID.

<iq to='{user-jid/resource}' id='discoitem1' from='domain' type='result'>
<query xmlns='http://jabber.org/protocol/disco#items'>
<item name='User Search' jid='search.domain'></item>
<item name='Socks 5 Bytestreams Proxy' jid='proxy.domain'></item>
<item name='Public Chatrooms' jid='conference.domain'></item>
<item name='Publish-Subscribe service' jid='pubsub.domain'></item>
</query>
</iq>

Once user gets all available services. It needs to be confirm whether conference service is there or not. If it is available user can ask for available chat rooms. These are all persistent chat rooms on the server.

<iq from='{user-jid/resource}' id='discoRooms' to='conference.domain' type='get'>
<query xmlns='http://jabber.org/protocol/disco#items'/>
</iq>

Server will send back all back all available chat rooms in following XML format.

<iq to='{user-jid/resource}' id='discoRooms' from='conference.domain' type='result'>
<query xmlns='http://jabber.org/protocol/disco#items'>
<item name='university' jid='room1@conference.domain'></item>
<item name='country' jid='room2@conference.domain'></item>
</query>
</iq>

Now user is ready to join any room, he wants. User just needs to send one presence to the server. I will include more details about the same topic in next post. Stay in touch

0 comments:

Post a Comment