Class: RubyBOSH
- Inherits:
-
Object
- Object
- RubyBOSH
- Defined in:
- lib/ruby_bosh.rb
Defined Under Namespace
Classes: AuthFailed, ConnFailed, Error, Timeout
Constant Summary collapse
- BOSH_XMLNS =
'http://jabber.org/protocol/httpbind'
- TLS_XMLNS =
'urn:ietf:params:xml:ns:xmpp-tls'
- SASL_XMLNS =
'urn:ietf:params:xml:ns:xmpp-sasl'
- BIND_XMLNS =
'urn:ietf:params:xml:ns:xmpp-bind'
- SESSION_XMLNS =
'urn:ietf:params:xml:ns:xmpp-session'
- CLIENT_XMLNS =
'jabber:client'
- @@logging =
true
Instance Attribute Summary collapse
-
#custom_resource ⇒ Object
Returns the value of attribute custom_resource.
-
#jid ⇒ Object
Returns the value of attribute jid.
-
#rid ⇒ Object
Returns the value of attribute rid.
-
#sid ⇒ Object
Returns the value of attribute sid.
-
#success ⇒ Object
Returns the value of attribute success.
Class Method Summary collapse
Instance Method Summary collapse
- #connect ⇒ Object
-
#initialize(jid, pw, service_url, opts = {}) ⇒ RubyBOSH
constructor
A new instance of RubyBOSH.
- #success? ⇒ Boolean
Constructor Details
#initialize(jid, pw, service_url, opts = {}) ⇒ RubyBOSH
Returns a new instance of RubyBOSH.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ruby_bosh.rb', line 26 def initialize(jid, pw, service_url, opts={}) @service_url = service_url # Extract the resource if present split_jid = jid.split("/") @jid = split_jid.first @custom_resource = split_jid.last if split_jid.length > 1 @pw = pw @host = @jid.split("@").last @success = false @timeout = opts[:timeout] || 3 #seconds @headers = {"Content-Type" => "text/xml; charset=utf-8", "Accept" => "text/xml"} @wait = opts[:wait] || 5 @hold = opts[:hold] || 3 @window = opts[:window] || 5 end |
Instance Attribute Details
#custom_resource ⇒ Object
Returns the value of attribute custom_resource.
25 26 27 |
# File 'lib/ruby_bosh.rb', line 25 def custom_resource @custom_resource end |
#jid ⇒ Object
Returns the value of attribute jid.
25 26 27 |
# File 'lib/ruby_bosh.rb', line 25 def jid @jid end |
#rid ⇒ Object
Returns the value of attribute rid.
25 26 27 |
# File 'lib/ruby_bosh.rb', line 25 def rid @rid end |
#sid ⇒ Object
Returns the value of attribute sid.
25 26 27 |
# File 'lib/ruby_bosh.rb', line 25 def sid @sid end |
#success ⇒ Object
Returns the value of attribute success.
25 26 27 |
# File 'lib/ruby_bosh.rb', line 25 def success @success end |
Class Method Details
.initialize_session(*args) ⇒ Object
47 48 49 |
# File 'lib/ruby_bosh.rb', line 47 def self.initialize_session(*args) new(*args).connect end |
.logging=(value) ⇒ Object
21 22 23 |
# File 'lib/ruby_bosh.rb', line 21 def self.logging=(value) @@logging = value end |
Instance Method Details
#connect ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/ruby_bosh.rb', line 51 def connect initialize_bosh_session if send_auth_request send_restart_request request_resource_binding @success = send_session_request end raise RubyBOSH::AuthFailed, "could not authenticate #{@jid}" unless success? @rid += 1 #updates the rid for the next call from the browser [@jid, @sid, @rid] end |
#success? ⇒ Boolean
43 44 45 |
# File 'lib/ruby_bosh.rb', line 43 def success? @success == true end |