0

我正在尝试使用 HTML5、WebSockets、strophe-openfire.js 库进行实时聊天(https://code.google.com/p/openfire-websockets/source/browse/trunk/src/ofchat/js/strophejs /src/strophe-openfire.js)和 Openfire 服务器。
我使用此代码段进行连接:

function connectHandler(cond) {  
    log("connected");  
    connection.send($pres());  
}

var url = "ws://localhost:7070/ws";    
connectButton.onclick = function() {  
   var username = document.getElementById("username").value;  
   var password = document.getElementById("password").value;  
    var connection = new Openfire.Connection (url);  
   connection.connect(username, password,  connectHandler);  
}

我在客户端会话选项卡中的 Openfire 管理控制台上看到用户已“经过身份验证”但仍处于脱机状态。在 Chrome 控制台上,我看到来自 Openfire 的响应,其中包含101 个切换协议和适当的标头,但仅此而已。

所以我的问题是什么可能是connection.send($pres())不起作用的原因以及如何将存在发送到 Openfire。

提前致谢。
安德鲁

4

1 回答 1

0

抱歉,我无法回答,但我遇到了完全相同的问题。我的 Openfire 服务器建立了 websocket 连接,但从不返回响应:

<?xml version='1.0'?><stream:stream to='satellite-l675' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en' xmlns:xml="http://www.w3.org/XML/1998/namespace">

我正在使用带有 .0006 websocktet 插件的 Openfire 3.8.2。我正在尝试使用 Candy chat 作为客户端。

我无意中通过绕过身份验证并发送它来与 Openfire websocket 通信:

发送: <stream:stream to='satellite-l675' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'/>

发送: <presence xmlns='jabber:client'/>

发送: <iq type='get' from='@satellite-l675/Candy' to='welcome@conference.satellite-l675' id='disco3' xmlns='jabber:client'> <query xmlns='http://jabber.org/protocol/disco#info'/> </iq>

发送: <presence from='satellite-l675/Candy' to='welcome@conference.satellite-l675/yogi' xmlns='jabber:client'> <x xmlns='http://jabber.org/protocol/muc'/> </presence>

发送: <iq type='get' from='@satellite-l675/Candy' id='get1' xmlns='jabber:client'> <query xmlns='jabber:iq:privacy'> <list name='ignore'/> </query> </iq>

接收: <body rid='3282533506' xmlns='http://jabber.org/protocol/httpbind'> <presence xmlns='jabber:client' from='welcome@conference.satellite-l675/yogi' to='msos_ws_candy@satellite-l675/MSOS_ws_Candy'> <x xmlns='http://jabber.org/protocol/muc#user'> <item affiliation='none' role='participant'/> </x> </presence> </body>

所以 websocket 可以工作,但要理解为什么以及如何工作并不容易。有趣的是,Openfire 附带的 SparkWeb 演示工作正常,但只发送<iq>'s. 它甚至似乎都不在乎这些<stream:...this...>东西<stream:...that...>

因此,鉴于文档有限,我只能得出结论,Openfire Websockets 仅使用<iq>'s,而我唯一成功的通信是由于<iq>发送了请求的 disco#info。

那么我们如何发送认证请求呢?任何对好的示例或文档的引用将不胜感激。

于 2013-08-15T16:56:41.817 回答