Sha256: 7bde1254e825770810bc7786a7c39e2b8d2cf4b4a9d353e52bca0c43e79b0801

Contents?: true

Size: 907 Bytes

Versions: 1

Compression:

Stored size: 907 Bytes

Contents

module EventMachine
  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
      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

1 entries across 1 versions & 1 rubygems

Version Path
em-websocket-0.2.0 lib/em-websocket/handler.rb