Class: Jabber::Simple
- Inherits:
-
Object
- Object
- Jabber::Simple
- Defined in:
- lib/messenger/jabber.rb
Instance Method Summary collapse
- #connect! ⇒ Object
-
#initialize(jid, password, host = nil, status = nil, status_message = "Available") ⇒ Simple
constructor
A new instance of Simple.
Constructor Details
#initialize(jid, password, host = nil, status = nil, status_message = "Available") ⇒ Simple
Returns a new instance of Simple.
56 57 58 59 60 61 62 63 |
# File 'lib/messenger/jabber.rb', line 56 def initialize(jid, password, host=nil, status=nil, ="Available") @jid = jid @password = password @host = host @disconnected = false status(status, ) start_deferred_delivery_thread end |
Instance Method Details
#connect! ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/messenger/jabber.rb', line 65 def connect! raise ConnectionError, "Connections are disabled - use Jabber::Simple::force_connect() to reconnect." if @disconnected # Pre-connect @connect_mutex ||= Mutex.new # don't try to connect if another thread is already connecting. return if @connect_mutex.locked? @connect_mutex.lock disconnect!(false) if connected? # Connect jid = JID.new(@jid) my_client = Client.new(@jid) my_client.connect(@host) my_client.auth(@password) self.client = my_client # Post-connect register_default_callbacks status(@presence, @status_message) @connect_mutex.unlock end |