class Vines::Stream::Server::Outbound::Authoritative

Constants

TO
TYPE

Public Class Methods

new(stream, success=nil) click to toggle source
Calls superclass method
# File lib/vines/stream/server/outbound/authoritative.rb, line 11
def initialize(stream, success=nil)
  super
end

Public Instance Methods

node(node) click to toggle source
# 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

Private Instance Methods

authoritative?(node) click to toggle source
# File lib/vines/stream/server/outbound/authoritative.rb, line 40
def authoritative?(node)
  @inbound = stream.router.stream_by_id(node[ID])
  node.name == VERIFY && namespace(node) == NAMESPACES[:legacy_dialback] && !@inbound.nil?
end