Parent

WebSocket::Frame::Data

Public Class Methods

new(*args) click to toggle source
# File lib/websocket/frame/data.rb, line 5
def initialize(*args)
  super *args.each { |arg| arg.force_encoding('ASCII-8BIT') if respond_to?(:force_encoding) }
end

Public Instance Methods

<<(*args) click to toggle source
# File lib/websocket/frame/data.rb, line 9
def <<(*args)
  super *args.each { |arg| arg.force_encoding('ASCII-8BIT') if respond_to?(:force_encoding) }
end
getbyte(index) click to toggle source
# File lib/websocket/frame/data.rb, line 30
def getbyte(index)
  self[index]
end
getbytes(start_index, count) click to toggle source
# File lib/websocket/frame/data.rb, line 22
def getbytes(start_index, count)
  data = self[start_index, count]
  data = mask(data.bytes.to_a, @masking_key).pack('C*') if @masking_key
  data
end
mask(payload, mask) click to toggle source
# File lib/websocket/frame/data.rb, line 35
def mask(payload, mask)
  return mask_native(payload, mask) if respond_to?(:mask_native)
  result = []
  payload.each_with_index do |byte, i|
    result[i] = byte ^ mask[i % 4]
  end
  result
end
set_mask() click to toggle source
# File lib/websocket/frame/data.rb, line 13
def set_mask
  raise "Too short" if bytesize < 4 # TODO - change
  @masking_key = self[0..3].bytes.to_a
end
unset_mask() click to toggle source
# File lib/websocket/frame/data.rb, line 18
def unset_mask
  @masking_key = nil
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.