1
votes
MultiUserChatManager manager = MultiUserChatManager.getInstanceFor(xmppconnection.getConnection());
try {
    MultiUserChat muc = manager.getMultiUserChat("[email protected]");

    muc.join("[email protected]");

    Message msg = new Message("[email protected]", Message.Type.groupchat);
    msg.setBody("Hi Testing..Group chat..");
    muc.sendMessage(msg);
    // muc.join("test", "1234");
} catch (SmackException.NotConnectedException e) {
    e.printStackTrace();
} catch (SmackException e) {
    e.printStackTrace();
} catch (XMPPException.XMPPErrorException e) {
    e.printStackTrace();
} catch (XMPPException e) {
    e.printStackTrace();
}

Error is:

error code="403" type="auth" forbidden xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>**

1
is it room id.. getMultiUserChat("[email protected]");?SRB Bans
yes its room id. getting information of user but unable to send message after joining the group.shjee hyder
@DimaSan yes it isshjee hyder
n what is this .. muc.join("[email protected]");.. i think it should be user_id.. not group id.SRB Bans
@sourabhbans its group id and i want to send message to groupshjee hyder

1 Answers

0
votes

There are several errors, logical and procedurals.

With this invocation:

 MultiUserChat muc = manager.getMultiUserChat("[email protected]");

you have in muc object your groupchat. So you need to check if you already joined this groupchat or double join will raise an exception.

so

if (!muc.isJoined())
 muc.join("My nickname");

more, when you join, you MUST provide an unique nickname per User to join, or you'll obtain an exception with the second user. Set as nickname the same name of the groupchat it's 99% a logical error.

Finally, to send a message, just send it through MUC object or you'll risk, like in this case, to miss some information.

So just send it with

muc.send("Hi Testing..Group chat..");

Last but not least: of course multiuserchat must exists or inititilized before properly, it's a prerequisite to do all this. As first step, just create it in Openfire with http-admin-panel (make it persistant)