Class: AgentXmpp::Connection
- Inherits:
-
EventMachine::Connection
- Object
- EventMachine::Connection
- AgentXmpp::Connection
- Includes:
- EventMachine::XmlPushParser
- Defined in:
- lib/agent_xmpp/client/connection.rb
Overview
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
———————————————————————————————————.
-
#delegates ⇒ Object
readonly
———————————————————————————————————.
-
#keepalive ⇒ Object
readonly
———————————————————————————————————.
-
#pipe ⇒ Object
readonly
———————————————————————————————————.
Instance Method Summary collapse
-
#characters(text) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#connection_completed ⇒ Object
——————————————————————————————————— EventMachine::Connection callbacks .….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#end_element(name) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#error(*args) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#initialize(client) ⇒ Connection
constructor
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#process ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#receive(stanza) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#receive_data(data) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#start_document ⇒ Object
——————————————————————————————————— EventMachine::XmlPushParser callbacks .….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#start_element(name, attrs) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#unbind ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
Constructor Details
#initialize(client) ⇒ Connection
.….….….….….….….….….….….….….….….….….….….….….….….….….….
16 17 18 19 |
# File 'lib/agent_xmpp/client/connection.rb', line 16 def initialize(client) @client = client @pipe = MessagePipe.new(self) end |
Instance Attribute Details
#client ⇒ Object (readonly)
12 13 14 |
# File 'lib/agent_xmpp/client/connection.rb', line 12 def client @client end |
#delegates ⇒ Object (readonly)
12 13 14 |
# File 'lib/agent_xmpp/client/connection.rb', line 12 def delegates @delegates end |
#keepalive ⇒ Object (readonly)
12 13 14 |
# File 'lib/agent_xmpp/client/connection.rb', line 12 def keepalive @keepalive end |
#pipe ⇒ Object (readonly)
12 13 14 |
# File 'lib/agent_xmpp/client/connection.rb', line 12 def pipe @pipe end |
Instance Method Details
#characters(text) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
73 74 75 |
# File 'lib/agent_xmpp/client/connection.rb', line 73 def characters(text) @current.text = @current.text.to_s + text if @current end |
#connection_completed ⇒ Object
EventMachine::Connection callbacks .….….….….….….….….….….….….….….….….….….….….….….….….….….
24 25 26 27 28 29 |
# File 'lib/agent_xmpp/client/connection.rb', line 24 def connection_completed @keepalive = EventMachine::PeriodicTimer.new(60) do send_data("\n") end pipe.connection_completed end |
#end_element(name) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
63 64 65 66 67 68 69 70 |
# File 'lib/agent_xmpp/client/connection.rb', line 63 def end_element(name) if @current.parent @current = @current.parent else process @current = nil end end |
#error(*args) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
78 79 80 |
# File 'lib/agent_xmpp/client/connection.rb', line 78 def error(*args) AgentXmpp.logger.error *args end |
#process ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/agent_xmpp/client/connection.rb', line 83 def process @current.add_namespace(@streamns) if @current.namespace('').to_s.eql?('') begin stanza = Xmpp::Stanza::import(@current) rescue Xmpp::NoNameXmlnsRegistered stanza = @current end if @current.xpath.eql?('stream:stream') @streamns = @current.namespace('') if @current.namespace('') end receive(stanza) if respond_to?(:receive) end |
#receive(stanza) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
97 98 99 |
# File 'lib/agent_xmpp/client/connection.rb', line 97 def receive(stanza) pipe.receive(stanza) end |
#receive_data(data) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
32 33 34 |
# File 'lib/agent_xmpp/client/connection.rb', line 32 def receive_data(data) super(data) end |
#start_document ⇒ Object
EventMachine::XmlPushParser callbacks .….….….….….….….….….….….….….….….….….….….….….….….….….….
48 49 |
# File 'lib/agent_xmpp/client/connection.rb', line 48 def start_document end |
#start_element(name, attrs) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
52 53 54 55 56 57 58 59 60 |
# File 'lib/agent_xmpp/client/connection.rb', line 52 def start_element(name, attrs) e = REXML::Element.new(name) e.add_attributes(attrs) @current = @current.nil? ? e : @current.add_element(e) if @current.xpath == 'stream:stream' process @current = nil end end |
#unbind ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
37 38 39 40 41 42 43 |
# File 'lib/agent_xmpp/client/connection.rb', line 37 def unbind if @keepalive @keepalive.cancel @keepalive = nil end pipe.unbind end |