Xmpp 如何使用JsJac实现群组聊天(MUC)?
我正在寻找使用XMPP javascript库JSJac实现群聊的示例代码。刚刚完成了使用XMPP、muckl 4.4和OpenFire的群聊。关键问题是如何启动并运行反向代理。由于JSJac在许多情况下使用http绑定,因此必须与http绑定服务器通信。这些服务器通常位于与提供javascript文件的web服务器不同的端口上 这会导致跨域冲突,并且无法正常工作。这里有一个很好的链接,可以讨论这个问题:Xmpp 如何使用JsJac实现群组聊天(MUC)?,xmpp,Xmpp,我正在寻找使用XMPP javascript库JSJac实现群聊的示例代码。刚刚完成了使用XMPP、muckl 4.4和OpenFire的群聊。关键问题是如何启动并运行反向代理。由于JSJac在许多情况下使用http绑定,因此必须与http绑定服务器通信。这些服务器通常位于与提供javascript文件的web服务器不同的端口上 这会导致跨域冲突,并且无法正常工作。这里有一个很好的链接,可以讨论这个问题: 假设您已经连接到jabber(con),下面是一个如何连接到群聊的快速示例 //Set t
假设您已经连接到jabber(con),下面是一个如何连接到群聊的快速示例
//Set the JID with resource
//Example: my_username@my_domain/my_chat_client
var u_jid = "my_username@my_domain/my_chat_client"
//Set the Full Room ID with your username as the resource
//Example: room_name@conference.my_domain/my_username
var full_room_id = "room_name@conference.my_domain/my_username";
var joinPacket = new JSJaCPresence();
joinPacket.setTo(full_room_id);
//Build item affiliation element
var inode = joinPacket.buildNode("item");
inode.setAttribute("affiliation","none");
inode.setAttribute("jid",u_jid);
inode.setAttribute("role","participant");
//Build X Element (with item affiliation child)
var xnode = joinPacket.buildNode("x", [inode]);
xnode.setAttribute("xmlns", "http://jabber.org/protocol/muc#user");
//Append new nodes to join packet
joinPacket.appendNode(xnode);
//Set status in room
joinPacket.setStatus('available');
var success = con.send(joinPacket, function(data) { console.log(data.getDoc()); });