2

XMPP4r gemを使用してjabberサーバーに接続した後、SIDとRIDを取得する方法に問題があります。正常に接続でき、JavaScriptに渡すために必要なのはSIDとRIDだけです。

ここでドキュメントを検索しましたが、あまり役に立ちませんでした。

どんな助けや提案も大歓迎です。ありがとう!

4

2 に答える 2

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-08-18T22:44:51.497 に答える
2

他の誰かが将来同じ障害に遭遇する場合に備えて、次のようにインスタンス変数に直接アクセスすることでこれを解決しました。

まず、クライアントの代わりに 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 クライアントで使用できるようにしました。

于 2012-08-22T06:18:57.953 に答える