Openfire multiuserchat multi-user chat-create a chat room

Source: Internet
Author: User

After the user sends the query IQ message, the user then sends the presence message to create a chat room:

<Presence id = "8li34-12" to = "roomname@conference.myserver/clienta"> <br/> <X xmlns = "http://jabber.org/protocol/muc"> </x> <br/> </presence>
The processing sequence diagram is as follows:

1. The presence message sent by the user is routed to the chatservice for processing.

2. The chatservice stores a view of all users in the local chat room. If you have already joined the chat room, you can quickly find the corresponding information here.

When a chat room is created for the first time, no corresponding user exists. So it will be created here and added to the view.

3. after a new muc user is created, the message is sent to him for processing. Each muc user maintains a corresponding table of their room and corresponding role, obtain this role before processing a message. The first time is null.

4. 5.6 if the existing room is not found in the chatservice, an existing room will be created. At the same time, the system tries to load the previous configuration from the database and add itself to owners.

. After obtaining the room, formally Add yourself to the room. Different from the previous steps, the corresponding role will be generated for the user.

9. After you add yourself to the room, you can get the status of all the existing participants.

10. broadcast your status to all participants.

11. Obtain historical chat records without explicit requirements.

12.13 update the last activity time of participants in the room.

After the room is created, the server returns the corresponding notification:

<Presence id = "8li34-12" to = "clienta @ myserver/spark" from = "roomname@conference.myserver/clienta"> <br/> <X xmlns = "http://jabber.org/protocol/muc#user"> <br/> <item jid = "clienta @ myserver/spark" affiliation = "owner" role = "moderator"/> <br/> <status code = "201"/> <br/> </x> <br/> </presence>

In this case, a default initial room is created and the status is locked. If the creator needs a long-standing room, the room needs to be configured.

First, query the parameters required for the Configuration:

<IQ id = "Dfs321-1" to = "myroom@conference.myserver" type = "get"> <br/> <query xmlns = "http://jabber.org/protocol/muc#owner"> </query> <br/> </ IQ>
The server returns all required configuration items:

<IQ type = "result" id = "Dfs321-1" from = "myroom@conference.myserver" to = "clienta @ myserver/spark"> <br/> <query xmlns = "http://jabber.org/protocol/muc#owner"> <br/> <X xmlns = "jabberx: data "type =" from "> <br/> <titile> room configuration </titile> <br/> <instruction> the room" myroom "has been created .... </instruction> <br/> <field Var = "from_type" type = "hidden"> <br/> <value> http://jabber.org/protocol/muc#roomconfig </value> <br/> </Field> <br/> ...... <br/> </x> <br/> </query> <br/> </IQ> <br/>

The client sends the corresponding configuration information to the server based on the preceding configuration items:

<IQ id = "feSe-1" to = "myroom@conference.myserver" type = "set"> <br/> <query xmlns = "http://jabber.org/protocol/muc#owner"> <br/> <X xmlns = "jabber: x: data "type =" Submit "> <br/> <field Var =" from_type "type =" hidden> <br/> <value> http://jabber.org/protocol/muc#roomconfig </value> <br/> .... <br/> </x> <br/> </query> <br/> </IQ> <br/>After the configuration is complete, the server will send the corresponding result and set the room status to unlock, so that others can join the room.

PS: You can also create a temporary room. For more information, see the XMPP protocol.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.