Search code examples
xmppstrophemuc

strophe js MUC room


I have created room from desktop client. And want to send message and receive messages on this room using strophejs. I have already set muc plugin, but I don't see any documentation of it. 1) how to subscribe on messages in room 2) how to send messages to room


Solution

  • First, read http://xmpp.org/extensions/xep-0045.html if you haven't already.

    By joining a room, you should get the messages, when sending messages, you send the message to the room jid instead of an individual.

    To join a room (after attaching/connecting to jabber server):

    connection.muc.join(room, nick, msg_handler_cb, pres_handler_cb, roster_cb, password, history_attrs);

    room is the jid of the room and nick is your nickname. You will need to write callback functions for handling the messages, rosters and presences (msg_handler_cb, pres_handler_cb,roster_cb). Password can be null if one is not required. Your history attributes define things line maxstanzas, which define how far back to get messages when loading.