Sha256: f7f8d8f26ad6f0dff7f5be52fb8ed980bf3de862471d31708d81d3d3a8f13e23

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

# encoding: BINARY

module EventMachine
  module WebSocket
    module MessageProcessor03
      def message(message_type, extension_data, application_data)
        case message_type
        when :close
          if @state == :closing
            # TODO: Check that message body matches sent data
            # We can close connection immediately since there is no more data
            # is allowed to be sent or received on this connection
            @connection.close_connection
            @state = :closed
          else
            # Acknowlege close
            # The connection is considered closed
            send_frame(:close, application_data)
            @state = :closed
            @connection.close_connection_after_writing
          end
        when :ping
          # Pong back the same data
          send_frame(:pong, application_data)
        when :pong
          # TODO: Do something. Complete a deferrable established by a ping?
        when :text, :binary
          @connection.trigger_on_message(application_data)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
em-websocket-0.3.1 lib/em-websocket/message_processor_03.rb
em-websocket-0.3.0 lib/em-websocket/message_processor_03.rb