Module: AgentXmpp::Parser

Includes:
EventMachine::XmlPushParser
Included in:
Connection
Defined in:
lib/agent_xmpp/client/parser.rb

Overview


Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#stream_featuresObject (readonly)




12
13
14
# File 'lib/agent_xmpp/client/parser.rb', line 12

def stream_features
  @stream_features
end

#stream_mechanismsObject (readonly)




12
13
14
# File 'lib/agent_xmpp/client/parser.rb', line 12

def stream_mechanisms
  @stream_mechanisms
end

Instance Method Details

#characters(text) ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….….….



43
44
45
# File 'lib/agent_xmpp/client/parser.rb', line 43

def characters(text)
  @current.text = @current.text.to_s + text if @current
end

#end_element(name) ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….….….



33
34
35
36
37
38
39
40
# File 'lib/agent_xmpp/client/parser.rb', line 33

def end_element(name)
  if @current.parent
    @current = @current.parent
  else
    process
    @current = nil
  end
end

#error(*args) ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….….….



48
49
50
# File 'lib/agent_xmpp/client/parser.rb', line 48

def error(*args)
  AgentXmpp.logger.error *args
end

#processObject

.….….….….….….….….….….….….….….….….….….….….….….….….….….



53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/agent_xmpp/client/parser.rb', line 53

def process
  @current.add_namespace(@streamns) if @current.namespace('').to_s.eql?('')
  begin
    stanza = Jabber::XMPPStanza::import(@current)
  rescue Jabber::NoNameXmlnsRegistered
    stanza = @current
  end
  if @current.xpath.eql?('stream:stream')
    @streamns = @current.namespace('') if @current.namespace('')
  end
  receive(stanza) if respond_to?(:receive)
end

#start_documentObject


EventMachine::XmlPushParser callbacks .….….….….….….….….….….….….….….….….….….….….….….….….….….



18
19
# File 'lib/agent_xmpp/client/parser.rb', line 18

def start_document
end

#start_element(name, attrs) ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….….….



22
23
24
25
26
27
28
29
30
# File 'lib/agent_xmpp/client/parser.rb', line 22

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