问题
I am trying to create a chat room using StropheJS
My Code:
var presence = $pres({ to: "testRoom@conference@localhost/yashwanth, from: Strophe.getBareJidFromJid(connection.jid) });
Groupie.connection.send( presence.tree());
Groupie.connection.muc.createInstantRoom("testRoom@conference.localhost/yashwanth",
function(status) {
console.log("Room Created Successfully", status);
},
function(status) {
console.log("Error Creating Room", status);
});
While creating the room I am facing the below error.
I found that the roomJID should be in the format of room_name@conference@HOST@/nickname . So as per the format i send that. But it doesn't create the room.
Error Creating Room <iq xmlns="jabber:client" from=
"conference@conference.localhost" to="yashwanth@inst1.eab.com/
5441440311438943022710601" type="error" id="1:sendIQ"><query xmlns="http://
jabber.org/protocol/muc#owner">…</query><error code="404" type="cancel">
<item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"></item-not-
found><text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">Conference room
does not exist</text></error></iq>
And I am using ejabberd as my XMPP server. If the room creates then in which database able the details related to the room will be saved? Either it save in muc_registered
table or muc_room
table?
回答1:
To join a room in XMPP, you do not need to create it first.
What your code is doing is:
- It sends the presence to the room, meaning that you are joining it. If it does not exist it will be created.
- You try creating the room, which should always fails as the room always exists.
- You are asking where room is stored. It is not stored unless it is persistent, which is not the case in your example if you did not configure ejabberd to set default room options to persistent. Otherwise you need to edit room options as defined in XEP-0045 Multi User Chat to make it persistent. Persistent rooms are stored in Mnesia table
muc_room
. createInstantRoom
in StropheJS MUC plugin create room with default options, just like joining so I do not see why it would be needed here.
So, I cannot tell what you are trying to achieve with your code, but just send the presence to the room is enough to create a non-persistent chat room and join it. No need to call createInstantRoom
.
来源:https://stackoverflow.com/questions/31876352/error-creating-chat-room-strophejs-with-ejabberd