Sha256: 0ae746e8eb46c4c840b7008fee3dd1fb668d3fb438094d799e9cd9f9cd006dc5

Contents?: true

Size: 922 Bytes

Versions: 37

Compression:

Stored size: 922 Bytes

Contents

module Blather
class Stream

  # @private
  class Session < Features
    SESSION_NS = 'urn:ietf:params:xml:ns:xmpp-session'.freeze
    register SESSION_NS

    def initialize(stream, succeed, fail)
      super
      @to = @stream.jid.domain
    end

    def receive_data(stanza)
      @node = stanza
      case stanza.element_name
      when 'session'  then  session
      when 'iq'       then  check_response
      else                  fail!(UnknownResponse.new(stanza))
      end
    end

  private
    def check_response
      if @node[:type] == 'result'
        succeed!
      else
        fail!(StanzaError.import(@node))
      end
    end

    ##
    # Send a start session command
    def session
      response = Stanza::Iq.new :set
      response.to = @to
      response << (sess = XMPPNode.new('session', response.document))
      sess.namespace = SESSION_NS

      @stream.send response
    end
  end

end
end

Version data entries

37 entries across 37 versions & 2 rubygems

Version Path
blather-2.0.0 lib/blather/stream/features/session.rb
blather-1.2.0 lib/blather/stream/features/session.rb
blather-1.1.4 lib/blather/stream/features/session.rb
blather-1.1.3 lib/blather/stream/features/session.rb
blather-1.1.2 lib/blather/stream/features/session.rb
blather-1.1.1 lib/blather/stream/features/session.rb
blather-1.1.0 lib/blather/stream/features/session.rb
blather-1.0.0 lib/blather/stream/features/session.rb
blather-0.8.8 lib/blather/stream/features/session.rb
blather-0.8.7 lib/blather/stream/features/session.rb
blather-0.8.6 lib/blather/stream/features/session.rb
blather-0.8.5 lib/blather/stream/features/session.rb
blather-0.8.4 lib/blather/stream/features/session.rb
blather-0.8.3 lib/blather/stream/features/session.rb
blather-0.8.2 lib/blather/stream/features/session.rb
tp-blather-0.8.5 lib/blather/stream/features/session.rb
tp-blather-0.8.4 lib/blather/stream/features/session.rb
tp-blather-0.8.3 lib/blather/stream/features/session.rb
tp-blather-0.8.2 lib/blather/stream/features/session.rb
blather-0.8.1 lib/blather/stream/features/session.rb