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.



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

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



40
41
42
43
# File 'lib/grenache/websocket.rb', line 40

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