Class: DRb::WebSocket::CallbackServer
- Inherits:
-
Object
- Object
- DRb::WebSocket::CallbackServer
- Defined in:
- lib/drb/websocket/callback_server.rb
Defined Under Namespace
Classes: ServerSide
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #accept ⇒ Object
- #close ⇒ Object
-
#initialize(uri, config) ⇒ CallbackServer
constructor
A new instance of CallbackServer.
Constructor Details
#initialize(uri, config) ⇒ CallbackServer
Returns a new instance of CallbackServer.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/drb/websocket/callback_server.rb', line 6 def initialize(uri, config) @uri = uri @config = config @wsclient = WSClient.new(uri) @queue = Thread::Queue.new @wsclient.on(:message) do |event| = event.data sender_id = .shift(36).pack('C*') @queue << [sender_id, .pack('C*')] end end |
Instance Attribute Details
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
4 5 6 |
# File 'lib/drb/websocket/callback_server.rb', line 4 def uri @uri end |
Instance Method Details
#accept ⇒ Object
24 25 26 27 |
# File 'lib/drb/websocket/callback_server.rb', line 24 def accept (sender_id, ) = @queue.pop ServerSide.new(@wsclient, sender_id, , @config, @uri) end |
#close ⇒ Object
19 20 21 22 |
# File 'lib/drb/websocket/callback_server.rb', line 19 def close @wsclient.close @wsclient = nil end |