class 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 18
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 30
def error?
  !@error.nil?
end
incoming_masking?() click to toggle source
# File spec/support/frames_base.rb, line 5
def incoming_masking?
  @handler.masking?
end
outgoing_masking?() click to toggle source
# File spec/support/frames_base.rb, line 9
def outgoing_masking?
  false
end
support_type?() click to toggle source

Is selected type supported for selected handler?

# File lib/websocket/frame/base.rb, line 35
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 40
def supported_frames
  raise NotImplementedError
end