rubyxmpp4r

Getting RID and SID using XMPP4r


I'm having problems in how to get the SID and the RID after I connect to my jabber server using the XMPP4r gem. I can connect successfully and I just need the SID and RID to pass it to the javascript.

I've searched the docs here but it hasn't helped me much.

Any help or suggestions will be much appreciated. Thanks!


Solution

  • Just in case anyone else would encounter the same roadblock in the future, I solved this by accessing the instance variables directly like so:

    First, require the httpbinding client, instead of client

    require 'xmpp4r/httpbinding/client'
    

    then connect by doing

    @client = Jabber::HTTPBinding::Client.new("your_jabber_id_with/resource")
    @client.connect("your_bosh_url")
    @client.auth("your_jabber_password")
    

    The instance variables are @http_sid and @http_rid, and since they are not accessible I did

    sid = @client.instance_variable_get("@http_sid")
    rid = @client.instance_variable_get("@http_rid")
    

    Then I stored those variables in my session so that I can use them on my Strophe.js client.