Class: Grenache::WebsocketClient

Inherits:
Object
  • Object
show all
Defined in:
lib/grenache/websocket.rb

Instance Method Summary collapse

Constructor Details

#initialize(uri, &cb) ⇒ WebsocketClient



30
31
32
33
34
# File 'lib/grenache/websocket.rb', line 30

def initialize(uri, &cb)
  @uri = uri.sub("tcp://","ws://")
  @uri.prepend("ws://") unless @uri.start_with?("ws://")
  @callback = cb
end

Instance Method Details

#send(payload) ⇒ Object



36
37
38
39
# File 'lib/grenache/websocket.rb', line 36

def send payload
  ws_connect unless @connected
  @ws.send(payload)
end