Android chat room developed based on XMPP smack openfire (5) [invitation and invitation]

Source: Internet
Author: User

1. Invitation:

In a simple sentence, the jid of the invitee should be input during the invitation. The invitation information can be blank.

 

MUC. Invite (userjid, "let's chat ");

 

At the same time, we need to know what happened. When this statement is executed, a message will be sent to the server, as shown below:

<Message from = 'crone1 @ Shakespeare. logs/desktop 'To =' darkcave @ chat. shakespeare. comment '> <X xmlns = 'HTTP: // jabber.org/protocol/muc?user'> <invite to = 'hecate @ Shakespeare. comment '> <reason> come in and chat with our sister </reason> </invite> </x> </message>

2. Invited

If you are invited, you can enable a listener. If you want to enter the room, you can skip this step. If you have an invitation, you can directly enter the room. If you have a need, you can consider the following:

Multiuserchat. addinvitationlistener (constants. conn, new invitationlistener () {// corresponding parameter: connection, room jid, room name, included content, password, message @ overridepublic void invitationreceived (connection Conn, string room, string inviter, string reason, string password, message) {log. I (TAG, "received from" + inviter + "chat room invitation. Content included with the invitation: "+ reason); intent = new intent (mucservice. this, activitymultiroom. class); intent. setflags (intent. flag_activity_new_task); intent. putextra ("jid", room); intent. putextra ("action", "Join"); startactivity (intent );}});

 

 

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.