Class: Grenache::WebsocketClient
- Inherits:
-
Object
- Object
- Grenache::WebsocketClient
- Defined in:
- lib/grenache/websocket.rb
Instance Method Summary collapse
-
#initialize(uri, &cb) ⇒ WebsocketClient
constructor
A new instance of WebsocketClient.
- #send(payload) ⇒ Object
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 |