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'- @@logger =
nil
Instance Attribute Summary collapse
-
#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
- #attach(sid, rid) ⇒ Object
- #connect ⇒ Object
-
#initialize(jid, pw, service_url, opts = {}) ⇒ RubyBOSH
constructor
A new instance of RubyBOSH.
- #send_xml(&block) ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(jid, pw, service_url, opts = {}) ⇒ RubyBOSH
Returns a new instance of RubyBOSH.
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ruby_bosh.rb', line 30 def initialize(jid, pw, service_url, opts={}) @service_url = service_url @jid, @pw = jid, pw @host = jid.split("@").last @success = false @timeout = opts[:timeout] || 30 #seconds @headers = {"Content-Type" => "text/xml; charset=utf-8", "Accept" => "text/xml"} @wait = opts[:wait] || 60 @hold = opts[:hold] || 1 @window = opts[:window] || 10 end |
Instance Attribute Details
#jid ⇒ Object
Returns the value of attribute jid.
28 29 30 |
# File 'lib/ruby_bosh.rb', line 28 def jid @jid end |
#rid ⇒ Object
Returns the value of attribute rid.
28 29 30 |
# File 'lib/ruby_bosh.rb', line 28 def rid @rid end |
#sid ⇒ Object
Returns the value of attribute sid.
28 29 30 |
# File 'lib/ruby_bosh.rb', line 28 def sid @sid end |
#success ⇒ Object
Returns the value of attribute success.
28 29 30 |
# File 'lib/ruby_bosh.rb', line 28 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 |
.logger=(_logger) ⇒ Object
24 25 26 |
# File 'lib/ruby_bosh.rb', line 24 def self.logger=(_logger) @@logger = _logger end |
Instance Method Details
#attach(sid, rid) ⇒ Object
51 52 53 54 55 |
# File 'lib/ruby_bosh.rb', line 51 def attach(sid, rid) @sid = sid @rid = rid @success = true end |
#connect ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ruby_bosh.rb', line 57 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? self end |
#send_xml(&block) ⇒ Object
70 71 72 73 |
# File 'lib/ruby_bosh.rb', line 70 def send_xml(&block) request = construct_body(:sid => @sid, &block) response = deliver(request) end |
#success? ⇒ Boolean
43 44 45 |
# File 'lib/ruby_bosh.rb', line 43 def success? @success == true end |