Class: AgentXmpp::Xmpp::Iq

Inherits:
Stanza show all
Defined in:
lib/agent_xmpp/xmpp/iq.rb

Overview


Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Stanza

answer, #answer, #error, #from, #from=, #id, #id=, #normalize, #to, #to=, #type, #type=

Methods inherited from Element

#<<, class_for_name_xmlns, #clone, import, name_xmlns, name_xmlns_for_class, #parent=, #set_xml_lang, #typed_add, #xml_lang, #xml_lang=, xmpp_attribute, xmpp_child

Methods inherited from REXML::Element

#delete_elements, #first_element, #first_element_text, #import, import, #replace_element_text, #typed_add

Constructor Details

#initialize(type = nil, to = nil) ⇒ Iq

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



67
68
69
70
71
# File 'lib/agent_xmpp/xmpp/iq.rb', line 67

def initialize(type = nil, to = nil)
  super()
  self.to = to unless to.nil?
  self.type = type unless type.nil?
end

Class Method Details

.bind(pipe) ⇒ Object

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



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/agent_xmpp/xmpp/iq.rb', line 19

def bind(pipe)
  iq = new_bind(AgentXmpp.jid)
  Send(iq) do |r|
    if r.type == :result and full_jid = r.first_element('//jid') and full_jid.text
      AgentXmpp.jid = Jid.new(full_jid.text)                
      pipe.broadcast_to_delegates(:on_bind, pipe)
    elsif r.type.eql?(:error) and r.bind
      raise AgentXmppError, "resource bind failed"
    end
  end
end

.session(pipe) ⇒ Object

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



32
33
34
35
36
37
38
39
40
41
# File 'lib/agent_xmpp/xmpp/iq.rb', line 32

def session(pipe)
  iq = new_session
  Send(iq) do |r|
    if r.type == :result                
      pipe.broadcast_to_delegates(:on_start_session, pipe)
    elsif r.type.eql?(:error) and r.session
      raise AgentXmppError, "session start failed"
    end
  end
end

Instance Method Details

#querynsObject

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



74
75
76
# File 'lib/agent_xmpp/xmpp/iq.rb', line 74

def queryns
  (e = first_element('query')).nil? ? nil : e.namespace
end