2014-10-05 95 views
0

我需要在服務器端驗證Openfire XMPP會話,並將會話傳遞給strophe.js。但是,我找不到可用的預先綁定的庫。Node.js解決方案用於XMPP BOSH預綁定以返回SID和RID

我一直使用的https://github.com/node-xmpp/node-xmpp-client維護者,但我們沒能解決好以下幾個:

var XMPP = require('node-xmpp-client') 


var prebind = new XMPP({ 
    jid: '[email protected]', 
    password: 'holonarchy', 
    wait: 60, 
    bosh: { 
     url: 'http://localhost:7070/http-bind/', 
     prebind: function(error, data) { 
      if (error) throw new Error(error); 
      console.log(data); 
      return data 
      /* 
       data.sid 
       data.rid 
      */ 
     } 
    } 
}) 

prebind.on('online', function() { console.log('Connected') }); 

我使用Wireshark來驗證正確節越來越發送到我的BOSH端點,並且Openfire以正確的響應返回,但模塊從不返回回調。

發送:

接收:

<body xmlns="http://jabber.org/protocol/httpbind" xmlns:stream="http://etherx.jabber.org/streams" from="localhost" authid="8bdd62a3" sid="8bdd62a3" secure="true" requests="2" inactivity="30" polling="5" wait="10" hold="1" ack="1836153693" maxpause="300" ver="1.6"> 

任何有任何變通辦法或瞭解其他節點庫,可以做預綁定?

回答

0

我希望這個鏈接將幫助您請參考:https://github.com/node-xmpp/node-xmpp-client/issues/77

var XMPP = require('node-xmpp-client'); 
    var prebind = new XMPP({ 
     jid: '[email protected]', 
     password: 'xxx', 
     preferred: 'PLAIN', 
     wait: 10, 
     bosh: { 
      url: 'http://localhost:5280/http-bind/', 
      prebind: function (error, data) { 
       if (error) throw new Error(error); 
       data.jid = '[email protected]'; 
       console.log(data); 
       **return res.send(data);** 
      } 
     }, 
     reconnect: true 

    });