Class: Vines::Stream::Client::BindRestart

Inherits:
State
  • Object
show all
Defined in:
lib/vines/stream/client/bind_restart.rb

Constant Summary

Constants included from Node

Node::BODY, Node::STREAM

Instance Attribute Summary

Attributes inherited from State

#stream

Instance Method Summary collapse

Methods inherited from State

#==, #eql?, #hash

Methods included from Node

body?, namespace, stream?, to_stanza

Methods included from Log

#log, set_log_file

Constructor Details

#initialize(stream, success = Bind) ⇒ BindRestart

Returns a new instance of BindRestart.



7
8
9
# File 'lib/vines/stream/client/bind_restart.rb', line 7

def initialize(stream, success=Bind)
  super
end

Instance Method Details

#node(node) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/vines/stream/client/bind_restart.rb', line 11

def node(node)
  raise StreamErrors::NotAuthorized unless stream?(node)
  stream.start(node)
  doc = Document.new
  features = doc.create_element('stream:features') do |el|
    # Session support is deprecated, but like we do it for Adium
    # in the iq-session-stanza we have to serve the feature for Xabber.
    # Otherwise it will disconnect after authentication!
    el << doc.create_element('session', 'xmlns' => NAMESPACES[:session]) do |session|
      session << doc.create_element('optional')
    end
    el << doc.create_element('bind', 'xmlns' => NAMESPACES[:bind])
  end
  stream.write(features)
  advance
end