在使用XMPP4r gem连接到jabber服务器后,我遇到了如何获取SID和RID的问题。我可以成功连接,我只需要SID和RID将其传递给javascript。
我已经搜索了here文档,但它对我帮助不大。
任何帮助或建议都将非常感谢。谢谢!
发布于 2012-08-22 14:18:58
为了防止其他人在将来遇到同样的障碍,我通过直接访问实例变量解决了这个问题,如下所示:
首先,需要httpbinding客户端,而不是客户端
require 'xmpp4r/httpbinding/client'然后通过执行以下操作进行连接
@client = Jabber::HTTPBinding::Client.new("your_jabber_id_with/resource")
@client.connect("your_bosh_url")
@client.auth("your_jabber_password")实例变量是@http_sid和@http_rid,由于无法访问它们,因此我这样做了
sid = @client.instance_variable_get("@http_sid")
rid = @client.instance_variable_get("@http_rid")然后,我将这些变量存储在会话中,以便可以在Strophe.js客户端上使用它们。
发布于 2014-08-19 06:44:51
这就是我为所有Openfire用户做的事情:
require 'xmpp4r'
require 'xmpp4r/httpbinding/client'
class PageController < ApplicationController
def index
Jabber::debug = true
@client = Jabber::HTTPBinding::Client.new('sankalpsingha@sankalpmacbook') # This is the JID
@client.connect('http://localhost:7070/http-bind/') # This is the bosh address
@client.auth('sankalp') # This is the password
@sid = @client.instance_variable_get('@http_sid')
@rid = @client.instance_variable_get('@http_rid')
end
endhttps://stackoverflow.com/questions/11945565
复制相似问题