-2

I have done one to one chat using Chat Manager but how can I do Group chat in smack version 4.1.9.

MultiUserChatManager is not public in smack version 4.1.9, how can I use MultiUserChatManager for group chat.

Jd Prajapati
  • 1,953
  • 13
  • 24
  • Hi, there are tons of questions about groupchats. If your approach is just to read the code, be sure to read the javadoc too. Starts from a basic tutorial like the official one: http://download.igniterealtime.org/smack/docs/latest/documentation/extensions/muc.html . then feel free to continue with Stackoverflow with http://stackoverflow.com/questions/41140681/ and http://stackoverflow.com/questions/37875539 – MrPk Feb 23 '17 at 14:04

1 Answers1

-1

Its not working in 4.1.9 version, you can try this one:

public MultiUserChat mMultiUserChat;
private MultiUserChatManager mMultiUserChatManager;

mMultiUserChatManager = MultiUserChatManager.getInstanceFor(mAbstractXMPPConnection);
mMultiUserChatManager.addInvitationListener(this);

mMultiUserChat = mMultiUserChatManager.getMultiUserChat(room);
mMultiUserChat.addMessageListener(this);

try {
    mMultiUserChat.join(yournickname);

  //  mMultiUserChat.sendConfigurationForm(new Form(DataForm.Type.submit));

} catch (SmackException.NoResponseException e) {
    e.printStackTrace();
} catch (XMPPException.XMPPErrorException e) {
    e.printStackTrace();
} catch (SmackException.NotConnectedException e) {
    e.printStackTrace();
}

and for send message:

 Message msg = new Message(room, Message.Type.groupchat);
 msg.setBody(message);
 mMultiUserChat.sendMessage(msg);
Jd Prajapati
  • 1,953
  • 13
  • 24
  • protocol specs about multiuserchat it's not changed. https://xmpp.org/extensions/xep-0045.html So your code can works only in very single cases (join an already existing MUC without password). More, MultiUserChat object allow to just sent messages with a String body without configure a new Message as you had – MrPk Feb 24 '17 at 08:43