【问题标题】:Getting RID and SID using XMPP4r使用 XMPP4r 获取 RID 和 SID
【发布时间】:2012-08-10 08:19:49
【问题描述】:

在使用 XMPP4r gem 连接到我的 jabber 服务器后,我遇到了如何获取 SID 和 RID 的问题。我可以成功连接,我只需要将 SID 和 RID 传递给 javascript。

我搜索了文档here,但对我帮助不大。

任何帮助或建议将不胜感激。谢谢!

【问题讨论】:

    标签: ruby xmpp4r


    【解决方案1】:

    以防万一其他人将来会遇到同样的障碍,我通过像这样直接访问实例变量来解决这个问题:

    首先,需要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 客户端上使用它们。

    【讨论】:

    • 失败:HTTP 请求路径为空:S
    • Same error here... 请告诉我们您是如何解决 HTTP 请求路径空问题的?
    【解决方案2】:

    这就是我为所有 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
    end
    

    【讨论】:

      猜你喜欢
      • 2014-10-04
      • 1970-01-01
      • 1970-01-01
      • 2010-11-18
      • 1970-01-01
      • 2012-05-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多