Class: Blather::Stream::Register
- Defined in:
- lib/blather/stream/features/register.rb
Constant Summary collapse
- REGISTER_NS =
"http://jabber.org/features/iq-register".freeze
Instance Method Summary collapse
-
#initialize(stream, succeed, fail) ⇒ Register
constructor
A new instance of Register.
- #receive_data(stanza) ⇒ Object
- #register_query ⇒ Object
Methods inherited from Features
#fail!, #feature?, from_namespace, #next!, register, #succeed!
Constructor Details
Instance Method Details
#receive_data(stanza) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/blather/stream/features/register.rb', line 14 def receive_data(stanza) error_node = stanza.xpath("//error").first if error_node fail!(BlatherError.new(stanza)) elsif stanza['type'] == 'result' && (stanza.content.empty? || stanza.children.find { |v| v.element_name == "query" }) succeed! else @stream.send register_query end end |
#register_query ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/blather/stream/features/register.rb', line 26 def register_query node = Blather::Stanza::Iq::Query.new(:set) query_node = node.xpath('//query').first query_node['xmlns'] = 'jabber:iq:register' Nokogiri::XML::Builder.with(query_node) do |xml| xml.username @jid.node xml.password @pass end node end |