Module: Mongrel2::WebSocket

Includes:
Constants
Defined in:
lib/mongrel2/websocket.rb

Overview

The Mongrel2 WebSocket namespace module. Contains constants and classes for building WebSocket services.

class WebSocketEchoServer

  def handle_websocket_handshake( handshake )
      # :TODO: Sub-protocol/protocol version checks?
      return handshake.response
  end

  def handle_websocket( frame )

      # Close connections that send invalid frames
      if !frame.valid?
          res = frame.response( :close )
          res.set_close_status( WebSocket::CLOSE_PROTOCOL_ERROR )
          return res
      end

      # Do something with the frame
      ...
  end
end

References

Defined Under Namespace

Modules: Constants, FrameMethods Classes: ClientHandshake, Error, Frame, FrameError, HandshakeError, Request, Response, ServerHandshake

Constant Summary

Constants included from Constants

Constants::CLOSE_ABNORMAL_STATUS, Constants::CLOSE_BAD_DATA, Constants::CLOSE_BAD_DATA_TYPE, Constants::CLOSE_EXCEPTION, Constants::CLOSE_GOING_AWAY, Constants::CLOSE_MESSAGE_TOO_LARGE, Constants::CLOSE_MISSING_EXTENSION, Constants::CLOSE_MISSING_STATUS, Constants::CLOSE_NORMAL, Constants::CLOSE_POLICY_VIOLATION, Constants::CLOSE_PROTOCOL_ERROR, Constants::CLOSE_RESERVED, Constants::CLOSE_TLS_ERROR, Constants::CLOSING_STATUS_DESC, Constants::DEFAULT_CHUNKSIZE, Constants::FIN_FLAG, Constants::OPCODE, Constants::OPCODE_BITMASK, Constants::OPCODE_CONTROL_MASK, Constants::OPCODE_NAME, Constants::RSV1_FLAG, Constants::RSV2_FLAG, Constants::RSV3_FLAG, Constants::RSV_FLAG_MASK