Class: Cybertrain::WebSocket::Subscription
- Inherits:
-
Object
- Object
- Cybertrain::WebSocket::Subscription
- Defined in:
- cybertrain/websocket.rb
Overview
One registered feed, from subscribe. Distinctive accessor names and no #call (NOTES rules 10/34/40).
Instance Method Summary collapse
-
#on_message(&block) ⇒ Subscription
Sets the block called with each message:
|conn, data|, a Connection and the bytes (a text message is UTF-8 as the server sent it, not checked). -
#on_open(&block) ⇒ Subscription
Sets the block called after each (re)connect, before any message: send the subscription request here.
-
#sub_name ⇒ String
The name given to subscribe.
Instance Method Details
#on_message(&block) ⇒ Subscription
Sets the block called with each message: |conn, data|, a
Connection and the bytes (a text message is UTF-8 as the server
sent it, not checked). Required before Cybertrain::WebSocket.start!.
182 183 184 185 |
# File 'cybertrain/websocket.rb', line 182 def (&block) @sub_message_block = block self end |
#on_open(&block) ⇒ Subscription
Sets the block called after each (re)connect, before any message: send the subscription request here. It receives a Connection.
172 173 174 175 |
# File 'cybertrain/websocket.rb', line 172 def on_open(&block) @sub_open_block = block self end |
#sub_name ⇒ String
Returns the name given to Cybertrain::WebSocket.subscribe.
164 165 166 |
# File 'cybertrain/websocket.rb', line 164 def sub_name @sub_name end |