Method: Patch::IO::Websocket::Socket#on_message

Defined in:
lib/patch/io/websocket/socket.rb

#on_message(&callback) ⇒ Boolean

Parameters:

  • callback to fire when events are received

Returns:



32
33
34
35
36
37
38
39
# File 'lib/patch/io/websocket/socket.rb', line 32

def on_message(&callback)
  if @socket.nil?
    @onmessage << callback
  else
    @socket.onmessage { |data| yield(data) }
  end
  true
end