Sha256: 7d6b2a7beb7c71103351c8caafff96634d33b8a554ad2792ecb0a53310cae87d

Contents?: true

Size: 905 Bytes

Versions: 6

Compression:

Stored size: 905 Bytes

Contents

module Rack
  module WebSocket
    class Handler
      include Debugger

      attr_reader :request, :state

      def initialize(connection, request, debug = false)
        @connection, @request = connection, request
        @debug = debug
        @state = :handshake
        initialize_framing
      end

      def run
        @connection.send_data handshake
        @state = :connected
        @connection.trigger_on_open
      end

      # Handshake response
      def handshake
        # Implemented in subclass
      end

      def receive_data(data)
        @data << data
        process_data(data)
      end

      def close_websocket
        # Unless redefined in a subclass, just close the connection
        @state = :closed
        @connection.close_connection_after_writing
      end

      def unbind
        @state = :closed
        @connection.trigger_on_close
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
websocket-rack-0.1.4 lib/rack/websocket/handler.rb
websocket-rack-0.1.3.1 lib/rack/websocket/handler.rb
websocket-rack-0.1.3 lib/rack/websocket/handler.rb
websocket-rack-0.1.2 lib/rack/websocket/handler.rb
websocket-rack-0.1.1 lib/rack/websocket/handler.rb
websocket-rack-0.1.0 lib/rack/websocket/handler.rb