Class: Grenache::WebsocketClient

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

Instance Method Summary collapse

Constructor Details

#initialize(uri, &cb) ⇒ WebsocketClient

Returns a new instance of WebsocketClient.



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

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



42
43
44
45
# File 'lib/grenache/websocket.rb', line 42

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