Sha256: c579f2d33b3cc50b331180e0c6def7932309f70fa3996f639c1c84c66d28a771

Contents?: true

Size: 755 Bytes

Versions: 3

Compression:

Stored size: 755 Bytes

Contents

# frozen_string_literal: true

module Wamp
  module Connection
    # Client Session
    class Session
      attr_reader :joiner, :session, :store, :api
      attr_accessor :executor, :stream

      def initialize(joiner = Wampproto::Joiner.new("realm1"))
        @joiner = joiner
        @session = Wampproto::Session.new(joiner.serializer)
        @api = MessageHandler::Api.new(self)
        @store = {}
      end

      def on_join(&block)
        self.executor = block
      end

      def on_open
        stream.on_message joiner.send_hello
      end

      def on_message(data)
        handler = MessageHandler.resolve(data, self)
        handler.handle
      end

      def transmit(data)
        stream.on_message data
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
xconn-0.1.2 lib/wamp/connection/session.rb
xconn-0.1.1 lib/wamp/connection/session.rb
xconn-0.1.0 lib/wamp/connection/session.rb