Class: Vines::Stream::Server::Outbound::Authoritative

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

Constant Summary

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 = nil) ⇒ Authoritative

Returns a new instance of Authoritative.



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

def initialize(stream, success=nil)
  super
end

Instance Method Details

#node(node) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/vines/stream/server/outbound/authoritative.rb', line 15

def node(node)
  raise StreamErrors::NotAuthorized unless authoritative?(node)

  case node[TYPE]
  when VALID
    @inbound.write("<db:result xmlns:db='#{NAMESPACES[:legacy_dialback]}' " \
      "from='#{node[TO]}' to='#{node[FROM]}' type='#{node[TYPE]}'/>")
    @inbound.advance(Server::Ready.new(@inbound))
    @inbound.notify_connected
  when INVALID
    @inbound.write("<db:result xmlns:db='#{NAMESPACES[:legacy_dialback]}' " \
      "from='#{node[TO]}' to='#{node[FROM]}' type='#{node[TYPE]}'/>")
    @inbound.close_connection_after_writing
  else
    @inbound.write("<db:result xmlns:db='#{NAMESPACES[:legacy_dialback]}' " \
      "from='#{node[TO]}' to='#{node[FROM]}' type='#{ERROR}'>" \
      "<error type='cancel'><item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>" \
      "</error></db:result>")
    @inbound.close_connection_after_writing
  end
  stream.close_connection
end