Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions lib/em-websocket/framing07.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
module EventMachine
module WebSocket
module Framing07

def initialize_framing
@data = MaskedString.new
@application_data_buffer = '' # Used for MORE frames
@frame_type = nil
end

def process_data
error = false

Expand All @@ -35,7 +35,7 @@ def process_data
error = true
next
end

# Only using the last 4 bytes for now, till I work out how to
# unpack 8 bytes. I'm sure 4GB frames will do for now :)
l = @data.getbytes(pointer+4, 4).unpack('N').first
Expand All @@ -48,7 +48,7 @@ def process_data
error = true
next
end

l = @data.getbytes(pointer, 2).unpack('n').first
pointer += 2
l
Expand Down Expand Up @@ -81,7 +81,7 @@ def process_data
application_data = @data.getbytes(pointer, payload_length)
pointer += payload_length
@data.unset_mask if mask

# Throw away data up to pointer
@data.slice!(0...pointer)

Expand Down Expand Up @@ -120,15 +120,15 @@ def process_data
end
end # end while
end

def send_frame(frame_type, application_data)
debug [:sending_frame, frame_type, application_data]

if @state == :closing && data_frame?(frame_type)
raise WebSocketError, "Cannot send data frame since connection is closing"
end

frame = ''
frame = String.new

opcode = type_to_opcode(frame_type)
byte1 = opcode | 0b10000000 # fin bit set, rsv1-3 are 0
Expand Down
2 changes: 1 addition & 1 deletion lib/em-websocket/masking04.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def getbyte(index)
end

def getbytes(start_index, count)
data = ''
data = String.new
data.force_encoding('ASCII-8BIT') if data.respond_to?(:force_encoding)
count.times do |i|
data << getbyte(start_index + i)
Expand Down