Skip to content
Closed
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
9 changes: 7 additions & 2 deletions lib/websocket/driver/hybi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ def binary(message)
end

def ping(message = '', &callback)
@ping_callbacks[message] = callback if callback
frame(message, :ping)
sent = frame(message, :ping)
@ping_callbacks[message] = callback if sent && callback
sent
end

def pong(message = '')
Expand Down Expand Up @@ -172,6 +173,10 @@ def frame(buffer, type = nil, code = nil)
message.opcode = OPCODES[type]
message.data = payload

if !MESSAGE_OPCODES.include?(message.opcode) && payload.bytesize > 125
raise ArgumentError, 'Control frame payload cannot exceed 125 bytes'
end

if MESSAGE_OPCODES.include?(message.opcode)
message = @extensions.process_outgoing_message(message)
end
Expand Down