Sha256: 3157fb589455b4d1714101d1a7aef62147b7b69d3240f99143b99a62d53c97fe
Contents?: true
Size: 900 Bytes
Versions: 6
Compression:
Stored size: 900 Bytes
Contents
require 'tamashii/packet' module Tamashii module RSpec module Helpers def websocket_mask (1..4).map { rand 255 } end def websocket_mask_message(mask, *bytes) output = [] bytes.each_with_index do |byte, i| output[i] = byte ^ mask[i % 4] end output end def tamashii_packet(type, tag, body) Tamashii::Packet.new(type, tag, body).dump end def tamashii_binary_packet(type, tag, body) mask = websocket_mask packet = tamashii_packet(type, tag, body) [0x82, 0x80 + packet.size] + mask + websocket_mask_message(mask, *packet) end def tamashii_text_packet(type, tag, body) mask = websocket_mask packet = tamashii_packet(type, tag, body) [0x81, 0x80 + packet.size] + mask + websocket_mask_message(mask, *packet) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems