Class: WebSocket::Frame::Handler::Handler07

### Home Classes Methods

### In Files

- lib/websocket/frame/handler/handler07.rb

### Parent

WebSocket::Frame::Handler::Handler05

### Methods

- #decode_frame
- #encode_frame

### Class/Module Index

Quicksearch

- WebSocket
- WebSocket::Error
- WebSocket::Error::Frame
- WebSocket::Error::Frame::ControlFramePayloadTooLong
- WebSocket::Error::Frame::DataFrameInsteadContinuation
- WebSocket::Error::Frame::FragmentedControlFrame
- WebSocket::Error::Frame::Invalid
- WebSocket::Error::Frame::InvalidPayloadEncoding
- WebSocket::Error::Frame::MaskTooShort
- WebSocket::Error::Frame::ReservedBitUsed
- WebSocket::Error::Frame::TooLong
- WebSocket::Error::Frame::UnexpectedContinuationFrame
- WebSocket::Error::Frame::UnknownCloseCode
- WebSocket::Error::Frame::UnknownFrameType
- WebSocket::Error::Frame::UnknownOpcode
- WebSocket::Error::Frame::UnknownVersion
- WebSocket::Error::Handshake
- WebSocket::Error::Handshake::GetRequestRequired
- WebSocket::Error::Handshake::InvalidAuthentication
- WebSocket::Error::Handshake::InvalidHeader
- WebSocket::Error::Handshake::InvalidStatusCode
- WebSocket::Error::Handshake::NoHostProvided
- WebSocket::Error::Handshake::UnknownVersion
- WebSocket::ExceptionHandler
- WebSocket::ExceptionHandler::ClassMethods
- WebSocket::Frame
- WebSocket::Frame::Base
- WebSocket::Frame::Data
- WebSocket::Frame::Handler
- WebSocket::Frame::Handler::Base
- WebSocket::Frame::Handler::Handler03
- WebSocket::Frame::Handler::Handler04
- WebSocket::Frame::Handler::Handler05
- WebSocket::Frame::Handler::Handler07
- WebSocket::Frame::Handler::Handler75
- WebSocket::Frame::Incoming
- WebSocket::Frame::Incoming::Client
- WebSocket::Frame::Incoming::Server
- WebSocket::Frame::Outgoing
- WebSocket::Frame::Outgoing::Client
- WebSocket::Frame::Outgoing::Server
- WebSocket::Handshake
- WebSocket::Handshake::Base
- WebSocket::Handshake::Client
- WebSocket::Handshake::Handler
- WebSocket::Handshake::Handler::Base
- WebSocket::Handshake::Handler::Client
- WebSocket::Handshake::Handler::Client01
- WebSocket::Handshake::Handler::Client04
- WebSocket::Handshake::Handler::Client75
- WebSocket::Handshake::Handler::Client76
- WebSocket::Handshake::Handler::Server
- WebSocket::Handshake::Handler::Server04
- WebSocket::Handshake::Handler::Server75
- WebSocket::Handshake::Handler::Server76
- WebSocket::Handshake::Server

No matching classes.

# WebSocket::Frame::Handler::Handler07

### Constants

FRAME_TYPES

  Hash of frame names and it's opcodes

FRAME_TYPES_INVERSE

  Hash of frame opcodes and it's names

### Public Instance Methods

decode_frame() click to toggle source

    # File lib/websocket/frame/handler/handler07.rb, line 30
    def decode_frame
      result = super
      if has_close_code?(result)
        code = result.data.slice!(0..1)
        result.code = code.unpack('n').first
        raise WebSocket::Error::Frame::UnknownCloseCode unless valid_code?(result.code)
        raise WebSocket::Error::Frame::InvalidPayloadEncoding unless valid_encoding?(result.data)
      end
      result
    end

encode_frame() click to toggle source

    # File lib/websocket/frame/handler/handler07.rb, line 20
    def encode_frame
      if @frame.type == :close
        code = @frame.code || 1000
        raise WebSocket::Error::Frame::UnknownCloseCode unless valid_code?(code)
        @frame.data = Data.new([code].pack('n') + @frame.data.to_s)
        @frame.code = nil
      end
      super
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.