Class: Vines::Stream::Client::AuthRestart

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

Direct Known Subclasses

Server::AuthRestart

Constant Summary

Constants inherited from State

State::BODY, State::STREAM

Instance Attribute Summary

Attributes inherited from State

#stream

Instance Method Summary collapse

Methods inherited from State

#==, #eql?, #hash

Methods included from Log

#log

Constructor Details

#initialize(stream, success = Auth) ⇒ AuthRestart

Returns a new instance of AuthRestart.



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

def initialize(stream, success=Auth)
  super
end

Instance Method Details

#node(node) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/vines/stream/client/auth_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|
    el << doc.create_element('mechanisms') do |parent|
      parent.default_namespace = NAMESPACES[:sasl]
      stream.authentication_mechanisms.each do |name|
        parent << doc.create_element('mechanism', name)
      end
    end
  end
  stream.write(features)
  advance
end