【问题标题】:How do we extract the values of rid and sid from the strophe connection我们如何从 strophe 连接中提取 rid 和 sid 的值
【发布时间】:2014-04-24 12:48:19
【问题描述】:

我正在尝试从 strophe 连接中获取 SID、RID 和 JID 的值,并尝试将它们传递给 converse.js。我正在运行 strophe 附带的示例,我能够获取包含所有值的消息,但我无法从元素中检索值。

 <body rid='629033749' xmlns='http://jabber.org/protocol/httpbind' sid='c270b6b5' to='127.0.0.1' xml:lang='en' xmpp:restart='true' xmlns:xmpp='urn:xmpp:xbosh'/>

我尝试了 connection.sid 但返回未定义。有人可以帮我解决这个问题吗?

【问题讨论】:

  • 您的初始会话创建应该返回一个 SID。您最初是如何连接的?
  • 感谢Mark的回复……我用了connection._proto.rid后终于搞定了

标签: java xmpp strophe converse.js


【解决方案1】:

仅作记录, converse.js 的另一种方法是在初始化 converse.js 时设置为 true expose_rid_and_sid

converse.initialize({
     prebind: false,
     bosh_service_url: BOSH_SERVICE,
     show_controlbox_by_default: true,
     expose_rid_and_sid: true
});

然后你就不能用

获得 RID 和 SID
converse.getSID();
converse.getRID();

或者,如果你有更新的版本,你可以使用

converse.tokens.get('sid');
converse.tokens.get('rid');

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-10-04
    • 2012-08-10
    • 2015-11-10
    • 1970-01-01
    • 2018-01-15
    • 1970-01-01
    • 2014-08-15
    相关资源
    最近更新 更多