Class: Vines::Stream::Server::Outbound::AuthResult

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

Constant Summary collapse

SUCCESS =
'success'.freeze
FAILURE =
'failure'.freeze

Constants inherited from Vines::Stream::State

Vines::Stream::State::BODY, Vines::Stream::State::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 Log

#log

Constructor Details

#initialize(stream, success = FinalRestart) ⇒ AuthResult

Returns a new instance of AuthResult.



11
12
13
# File 'lib/vines/stream/server/outbound/auth_result.rb', line 11

def initialize(stream, success=FinalRestart)
  super
end

Instance Method Details

#node(node) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/vines/stream/server/outbound/auth_result.rb', line 15

def node(node)
  raise StreamErrors::NotAuthorized unless namespace(node) == NAMESPACES[:sasl]
  case node.name
  when SUCCESS
    stream.start(node)
    stream.reset
    advance
  when FAILURE
    stream.close_connection
  else
    raise StreamErrors::NotAuthorized
  end
end