Sha256: cd81ed09a0a84188aab7de8cef80e9f76df1cb7bfc854c6e0049a48791a94187

Contents?: true

Size: 1.03 KB

Versions: 32

Compression:

Stored size: 1.03 KB

Contents

# encoding: UTF-8

module Vines
  class Stream
    class Http
      class BindRestart < State
        def initialize(stream, success=Bind)
          super
        end

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

          doc = Document.new
          body = doc.create_element('body') do |el|
            el.add_namespace(nil, NAMESPACES[:http_bind])
            el.add_namespace('stream', NAMESPACES[:stream])
            el << doc.create_element('stream:features') do |features|
              features << doc.create_element('bind', 'xmlns' => NAMESPACES[:bind])
            end
          end
          stream.reply(body)
          advance
        end

        private

        def restart?(node)
          session = stream.valid_session?(node['sid'])
          restart = node.attribute_with_ns('restart', NAMESPACES[:bosh]).value rescue nil
          domain  = node['to'] == stream.domain
          session && body?(node) && domain && restart == 'true' && node['rid']
        end
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 4 rubygems

Version Path
diaspora-vines-0.2.0.develop.4 lib/vines/stream/http/bind_restart.rb
diaspora-vines-0.2.0.develop.3 lib/vines/stream/http/bind_restart.rb
diaspora-vines-0.2.0.develop.2 lib/vines/stream/http/bind_restart.rb
diaspora-vines-0.2.0.develop.1 lib/vines/stream/http/bind_restart.rb
diaspora-vines-0.1.28 lib/vines/stream/http/bind_restart.rb
lygneo-vines-0.1.5 lib/vines/stream/http/bind_restart.rb
lygneo-vines-0.1.1 lib/vines/stream/http/bind_restart.rb
diaspora-vines-0.1.27 lib/vines/stream/http/bind_restart.rb
diaspora-vines-0.1.26 lib/vines/stream/http/bind_restart.rb
diaspora-vines-0.1.25 lib/vines/stream/http/bind_restart.rb
diaspora-vines-0.1.24 lib/vines/stream/http/bind_restart.rb
vines-0.4.10 lib/vines/stream/http/bind_restart.rb
diaspora-vines-0.1.22 lib/vines/stream/http/bind_restart.rb
diaspora-vines-0.1.21 lib/vines/stream/http/bind_restart.rb
diaspora-vines-0.1.2 lib/vines/stream/http/bind_restart.rb
vines-0.4.9 lib/vines/stream/http/bind_restart.rb
vines-0.4.8 lib/vines/stream/http/bind_restart.rb
vines-0.4.7 lib/vines/stream/http/bind_restart.rb
vines-0.4.6 lib/vines/stream/http/bind_restart.rb
vinesmod-0.4.5.2 lib/vines/stream/http/bind_restart.rb