Class: WebSocket::Frame::Data

Inherits:
String
  • Object
show all
Defined in:
lib/seapig/client.rb

Instance Method Summary collapse

Instance Method Details

#getbytes(start_index, count) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/seapig/client.rb', line 11

def getbytes(start_index, count)
	data = self[start_index, count]
	if @masking_key
		payload_na = NArray.to_na(data,"byte")
		mask_na = NArray.to_na((@masking_key.pack("C*")*((data.size/4) + 1))[0...data.size],"byte")
		data = (mask_na ^ payload_na).to_s
	end
	data
end