Class: WebSocket::Frame::Base

### Home Classes Methods

### In Files

- lib/websocket/frame/base.rb

### Parent

Object

### Methods

- ::new
- #error?
- #inspect
- #support_type?
- #supported_frames

### Included Modules

- WebSocket::ExceptionHandler

### 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::Base

@abstract Subclass and override to implement custom frames

### Attributes

code[RW]
data[RW]
error[R]
type[R]
version[R]

### Public Class Methods

new(args = {}) click to toggle source

Initialize frame @param args [Hash] Arguments for frame @option args [String] :data default data for frame @option args [String] :type Type of frame - available types are "text", "binary", "ping", "pong" and "close"(support depends on draft version) @option args [Integer] :code Code for close frame. Supported by drafts > 05. @option args [Integer] :version Version of draft. Currently supported version are 75, 76 and 00-13.

    # File lib/websocket/frame/base.rb, line 16
    def initialize(args = {})
      @type = args[:type].to_sym if args[:type]
      @code = args[:code]
      @data = Data.new(args[:data].to_s)
      @version = args[:version] || DEFAULT_VERSION
      @handler = nil
      include_version
    end

### Public Instance Methods

error?() click to toggle source

Check if some errors occured @return [Boolean] True if error is set

    # File lib/websocket/frame/base.rb, line 28
    def error?
      !!@error
    end

inspect() click to toggle source

Recreate inspect as to_s was overwritten

    # File lib/websocket/frame/base.rb, line 43
    def inspect
      vars = self.instance_variables.map { |v| "#{v}=#{instance_variable_get(v).inspect}" }.join(', ')
      insp = "#{self.class}:0x%08x" % (self.__id__ * 2)
      "<#{insp} #{vars}>"
    end

support_type?() click to toggle source

Is selected type supported for selected handler?

    # File lib/websocket/frame/base.rb, line 33
    def support_type?
      @handler.supported_frames.include?(@type)
    end

supported_frames() click to toggle source

Implement in submodules

    # File lib/websocket/frame/base.rb, line 38
    def supported_frames
      raise NotImplementedError
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.