Sha256: 58958417ca5bf53a91862195d6dfa00dd7a0ee8016b7b5e58f820afb5f6fd9db

Contents?: true

Size: 889 Bytes

Versions: 3

Compression:

Stored size: 889 Bytes

Contents

# frozen_string_literal: true

require_relative "event"
require_relative "subscription"

module Wamp
  module Manager
    # no:doc
    class Base
      include WebSocket::Driver::EventEmitter
      attr_reader :session

      def initialize(options = {})
        super()
        @options = options
        @session = Session.new(self)
      end

      def transmit(data); end

      def on_message(message)
        manager = Manager::Event.resolve(message, session)
        manager.emit_event(message)
      end

      def auth
        @options.fetch(:auth, Auth::Anonymous.new)
      end

      def run
        message = Message::Hello.new("realm1")
        manager = Manager::Event::Hello.new(message, session)
        manager.add_event_listener # adds on :join event listener
      end

      def authenticate(challenge)
        auth.authenticate(challenge)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
xconn-0.1.2 lib/wamp/manager/base.rb
xconn-0.1.1 lib/wamp/manager/base.rb
xconn-0.1.0 lib/wamp/manager/base.rb