【问题标题】:How to get JID, SID and RID from actual version of Smack如何从 Smack 的实际版本中获取 JID、SID 和 RID
【发布时间】:2017-02-20 15:13:26
【问题描述】:

我有以下问题:

成功连接到 openfire 服务器后,如何获取这三个(JID、SID 和 RID)参数?使用 Babbler 获得它们相对容易,但使用 Smack 有点困难,即使不是不可能,也很难找到。

最好的问候。

【问题讨论】:

    标签: xmpp openfire smack


    【解决方案1】:

    你可以通过这个链接找到你需要的东西: Java - trying to prebind converse.js using bosh but not able to get the sid and rid...using the smack bosh

    其他方式,如果可以使用javascript获取jid、sid和rid,可以参考以下: 您可以先使用strophe.js 创建 bosh 绑定,然后从连接中获取它们。

    //I user local openfire here
    var BOSH_SERVICE = 'http://127.0.0.1:7070/http-bind/'; 
    var connection = null;  
    //you can get your usr and pwd in other way
    var jid = 'admin@127.0.0.1';
    var password = 'admin';
    
    connection = new Strophe.Connection(BOSH_SERVICE);
            connection.connect(jid,  
                    password,  
                    onConnect);
    

    然后像这样从onConnect() 函数中获取详细信息:

    function onConnect(status)  
    { 
        if (status == Strophe.Status.CONNECTED) { 
            //then you can get what you want
            console.log("---SID[" + connection._proto.sid + "] RID[" +  connection._proto.rid + "] JID[" + jid + "]");
        }
    }
    

    祝你好运!

    【讨论】:

      猜你喜欢
      • 2023-03-16
      • 1970-01-01
      • 2014-10-04
      • 2012-08-10
      • 1970-01-01
      • 1970-01-01
      • 2013-03-09
      • 2010-11-18
      • 2017-01-28
      相关资源
      最近更新 更多