Class: Bosh4r::Session

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/bosh4r/session.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#build_xml, #send_bosh_request

Constructor Details

#initialize(jabber_id, password, options = {}) ⇒ Session

Returns a new instance of Session.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/bosh4r/session.rb', line 25

def initialize(jabber_id, password, options = {})
  split_jabber_id = jabber_id.split('/')
  bare_jabber_id = split_jabber_id.first
  resource_name = split_jabber_id.last if split_jabber_id.size > 1

  @jabber_id = bare_jabber_id
  @password = password
  @host = @jabber_id.split('@').last

  @bosh_url = options[:bosh_url] || 'http://localhost:5280/http-bind'
  @timeout = options[:timeout] || 5     # Network timeout
  @wait = options[:wait] || 5           # Longest time the connection manager is allowed to wait before responding
  @hold = options[:hold] || 1           # Number of connections that the connection manager can hold
  @version = options[:version] || '1.0' # BOSH protocol version
  @rid = rand(1000)
  @resource_name = resource_name.nil? ? "bosh_#{Time.now.to_i.to_s(36)}" : resource_name
  connect
end

Instance Attribute Details

#jidObject (readonly)

Returns the value of attribute jid.



23
24
25
# File 'lib/bosh4r/session.rb', line 23

def jid
  @jid
end

#ridObject (readonly)

Returns the value of attribute rid.



23
24
25
# File 'lib/bosh4r/session.rb', line 23

def rid
  @rid
end

#sidObject (readonly)

Returns the value of attribute sid.



23
24
25
# File 'lib/bosh4r/session.rb', line 23

def sid
  @sid
end

Instance Method Details

#connected?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/bosh4r/session.rb', line 44

def connected?
  @connected
end