Sha256: 560fed23e5f071e56f9b62467bcc5965f3c037ef7c099ccf014ef47416bf96f7

Contents?: true

Size: 735 Bytes

Versions: 16

Compression:

Stored size: 735 Bytes

Contents

module Startback
  module Websocket
    module Hub
      module Middleware
        class CommandHandler

          def initialize(app, opts, &bl)
            @app = app
            @opts = opts
            @handler = bl
          end

          def call(event, socket, env)
            who = matches?(event) ? @handler : @app
            who.call(event, socket, env)
          end

        private

          def matches?(event)
            if event.headers[:command]
              event.headers[:command]&.to_sym === @opts[:name]
            else
              false
            end
          end

        end # class CommandHandler
      end # module Middleware
    end # module Hub
  end # module Websocket
end # module Startback

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
startback-websocket-0.17.4 lib/startback/websocket/hub/middleware/command_handler.rb
startback-websocket-0.17.3 lib/startback/websocket/hub/middleware/command_handler.rb
startback-websocket-0.17.2 lib/startback/websocket/hub/middleware/command_handler.rb
startback-websocket-0.17.1 lib/startback/websocket/hub/middleware/command_handler.rb
startback-websocket-0.17.0 lib/startback/websocket/hub/middleware/command_handler.rb
startback-websocket-0.16.0 lib/startback/websocket/hub/middleware/command_handler.rb
startback-websocket-0.15.5 lib/startback/websocket/hub/middleware/command_handler.rb
startback-websocket-0.15.4 lib/startback/websocket/hub/middleware/command_handler.rb
startback-websocket-0.15.3 lib/startback/websocket/hub/middleware/command_handler.rb
startback-websocket-0.15.2 lib/startback/websocket/hub/middleware/command_handler.rb
startback-websocket-0.15.1 lib/startback/websocket/hub/middleware/command_handler.rb
startback-websocket-0.15.0 lib/startback/websocket/hub/middleware/command_handler.rb
startback-websocket-0.14.4 lib/startback/websocket/hub/middleware/command_handler.rb
startback-websocket-0.14.3 lib/startback/websocket/hub/middleware/command_handler.rb
startback-websocket-0.14.2 lib/startback/websocket/hub/middleware/command_handler.rb
startback-websocket-0.14.1 lib/startback/websocket/hub/middleware/command_handler.rb