Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e732d1a2909c
Choose a base ref
...
head repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0d4c040abff3
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Jun 7, 2016

  1. Copy the full SHA
    976437a View commit details

Commits on Apr 11, 2017

  1. Merge pull request #2774 from lbguilherme/patch-4

    WebSocket: Add support for receiving binary messages
    Ary Borenszweig authored Apr 11, 2017
    Copy the full SHA
    0d4c040 View commit details
Showing with 9 additions and 0 deletions.
  1. +9 −0 src/http/web_socket.cr
9 changes: 9 additions & 0 deletions src/http/web_socket.cr
Original file line number Diff line number Diff line change
@@ -48,6 +48,9 @@ class HTTP::WebSocket
def on_message(&@on_message : String ->)
end

def on_binary(&@on_binary : Slice(UInt8) ->)
end

def on_close(&@on_close : String ->)
end

@@ -121,6 +124,12 @@ class HTTP::WebSocket
@on_message.try &.call(@current_message.to_s)
@current_message.clear
end
when Protocol::Opcode::BINARY
@current_message.write @buffer[0, info.size]
if info.final
@on_binary.try &.call(@current_message.to_slice)
@current_message.clear
end
when Protocol::Opcode::CLOSE
@current_message.write @buffer[0, info.size]
if info.final