Sha256: 52ce7eabf39f2dc5bf143f4041a992c862249408d18ad056dfb02b3333e343a3

Contents?: true

Size: 919 Bytes

Versions: 1

Compression:

Stored size: 919 Bytes

Contents

module WampRails
  module Command
    class BaseCommand
      attr_accessor :queue, :client

      # The callback object to place in the queue
      class CallbackArgs
        attr_accessor :result, :error, :details
        def initialize(result, error, details)
          self.result = result
          self.error = error
          self.details = details
        end
      end

      def initialize(client)
        self.queue = Queue.new
        self.client = client
      end

      # Returns the session from the client
      def session
        self.client.wamp.session
      end


      # Executes the command.  This is called by the library in the EM Thread
      def execute
        # Override when sub classing
      end

      # Used in sub-classes to handle the response
      def callback(result, error, details)
        self.queue.push(CallbackArgs.new(result, error, details))
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wamp_rails-0.0.2 lib/wamp_rails/commands/base_command.rb