Class: Vines::Stream::Client::Start

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

Direct Known Subclasses

Server::Start

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 = TLS) ⇒ Start

Returns a new instance of Start.



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

def initialize(stream, success=TLS)
  super
end

Instance Method Details

#node(node) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/vines/stream/client/start.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('starttls') do |tls|
      tls.default_namespace = NAMESPACES[:tls]
      tls << doc.create_element('required')
    end
  end
  stream.write(features)
  advance
end