Class: DRb::WebSocket::CallbackHandler
- Inherits:
-
Object
- Object
- DRb::WebSocket::CallbackHandler
- Defined in:
- lib/drb/websocket.rb
Instance Method Summary collapse
-
#initialize(uri) ⇒ CallbackHandler
constructor
A new instance of CallbackHandler.
- #on_message(data) ⇒ Object
- #on_session_start(ws) ⇒ Object
- #send(url, data) ⇒ Object
- #stream ⇒ Object
Constructor Details
#initialize(uri) ⇒ CallbackHandler
Returns a new instance of CallbackHandler.
50 51 52 53 |
# File 'lib/drb/websocket.rb', line 50 def initialize(uri) @uri = uri @queue = Thread::Queue.new end |
Instance Method Details
#on_message(data) ⇒ Object
55 56 57 58 59 |
# File 'lib/drb/websocket.rb', line 55 def (data) sio = StrStream.new sio.write(data.pack('C*')) @queue.push sio end |
#on_session_start(ws) ⇒ Object
61 62 63 |
# File 'lib/drb/websocket.rb', line 61 def on_session_start(ws) @ws = ws end |
#send(url, data) ⇒ Object
69 70 71 |
# File 'lib/drb/websocket.rb', line 69 def send(url, data) @ws.send(data.bytes) end |
#stream ⇒ Object
65 66 67 |
# File 'lib/drb/websocket.rb', line 65 def stream @queue.pop end |