Adding participants to XMPP chat rooms
Asked Answered
P

2

9

I want to implement Group Chat in my application, for that purpose i am using MUC chat rooms to implement the same.

Here I want to add a list of members( i have the JID's) to the room. I want to add them internally to all the members in the list. How can i add them without inviting them.

And after adding the members i want to implement a functionality that whenever a user of the chat room messages or chat, it should be delivered to all the other users.

The main problem is how to add members to the chat room

code:

private void createRoom(){

        MultiUserChat privateRoom = new MultiUserChat(connection, "[email protected]");
        try {
            privateRoom.join("gaurav","123456");
            privateRoom.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));
            System.out.println("Room Created!!!");

            Message message = new Message("[email protected]", Message.Type.normal);
            message.setBody("Happy User");

            privateRoom.sendMessage(message);



        } catch (XMPPException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
Promptbook answered 31/12, 2012 at 6:3 Comment(0)
P
2

XEP-0045 doesn't contain a scenario where a client is forcibly made a participant of a chat room. While you can send an invite to a contact (either directly to the user, or through the MUC server), the contact doesn't actually join the chat room until the contact's client requests to join the room.

Thus, adding a user to a chat room without inviting them requires special support in the user's client. Possibly, the client could be modified to automatically accept chat room invites from trusted contacts.

Pikeperch answered 30/5, 2014 at 11:53 Comment(2)
Can you please suggest a mechanism to invite the USER to group chat ? I am using a code with which I am able to invite the user, but the other end user is not receiving any invite (which can be listened in the invitation listener).Bramante
I would use the "Direct MUC Invitations" protocol described in XEP-0249. That's the method recommended for most cases in XEP-0045, section 7.8, and should have a better chance of getting to the other user.Pikeperch
H
0

I am aware of how late this answer it, but it may help a future Stack-Overflower

The answer is in room affiliations, supported by members-only MUC room config option.

Affiliations allow the domain owner to specifically name who can access the room, and mark them as member. That user then automatically has access to that room, without requiring an invitation.

Hopefully answered 5/8 at 13:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.