Class: Vines::Stream::Server::Start

Inherits:
Vines::Stream::State show all
Defined in:
lib/vines/stream/server/start.rb

Constant Summary collapse

FROM =
"from".freeze

Constants included from Node

Node::BODY, Node::STREAM

Instance Attribute Summary

Attributes inherited from Vines::Stream::State

#stream

Instance Method Summary collapse

Methods inherited from Vines::Stream::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 = AuthMethod) ⇒ Start

Returns a new instance of Start.



9
10
11
# File 'lib/vines/stream/server/start.rb', line 9

def initialize(stream, success=AuthMethod)
  super
end

Instance Method Details

#node(node) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/vines/stream/server/start.rb', line 13

def node(node)
  raise StreamErrors::NotAuthorized unless stream?(node)
  stream.start(node)
  doc = Document.new
  features = doc.create_element('stream:features', 'xmlns:stream' => NAMESPACES[:stream]) do |el|
    unless stream.dialback_retry?
      el << doc.create_element('starttls') do |tls|
        tls.default_namespace = NAMESPACES[:tls]
        tls << doc.create_element('required') if force_s2s_encryption?
      end
    end
    el << doc.create_element('dialback') do |db|
      db.default_namespace = NAMESPACES[:dialback]
    end
  end
  stream.write(features)
  advance
end