Class: XmppServer::Client
- Inherits:
-
Object
- Object
- XmppServer::Client
- Defined in:
- lib/xmpp_server.rb
Overview
xmpp client to push connect and push message to xmpp server
Instance Attribute Summary collapse
-
#jid ⇒ Object
Returns the value of attribute jid.
-
#password ⇒ Object
Returns the value of attribute password.
Class Method Summary collapse
Instance Method Summary collapse
- #auth ⇒ Object
- #connect ⇒ Object
-
#initialize(jid, password) ⇒ Client
constructor
A new instance of Client.
- #push(m) ⇒ Object
Constructor Details
#initialize(jid, password) ⇒ Client
Returns a new instance of Client.
20 21 22 23 24 |
# File 'lib/xmpp_server.rb', line 20 def initialize(jid, password) @jid = jid @password = password @client = Jabber::Client.new @jid end |
Instance Attribute Details
#jid ⇒ Object
Returns the value of attribute jid.
18 19 20 |
# File 'lib/xmpp_server.rb', line 18 def jid @jid end |
#password ⇒ Object
Returns the value of attribute password.
18 19 20 |
# File 'lib/xmpp_server.rb', line 18 def password @password end |
Class Method Details
.get_default_client ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/xmpp_server.rb', line 41 def get_default_client jid = "#{XmppServer::Config.username}@#{XmppServer::Config::server}/pusher" password = XmppServer::Config.password client = XmppServer::Client.new(jid, password) client.connect client.auth client end |
Instance Method Details
#auth ⇒ Object
30 31 32 |
# File 'lib/xmpp_server.rb', line 30 def auth @client.auth @password end |
#connect ⇒ Object
26 27 28 |
# File 'lib/xmpp_server.rb', line 26 def connect @client.connect end |
#push(m) ⇒ Object
34 35 36 37 38 |
# File 'lib/xmpp_server.rb', line 34 def push(m) to = "#{m.username}@#{XmppServer::Config.server}/nickname" msg = Jabber::Message::new(to, m.content).set_type(:normal).set_id(1) @client.send msg end |