Class: DRb::WebSocket::Server
- Inherits:
-
Object
- Object
- DRb::WebSocket::Server
- Defined in:
- lib/drb/websocket/server.rb
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #accept ⇒ Object
- #close ⇒ Object
-
#initialize(uri, config) ⇒ Server
constructor
A new instance of Server.
- #on_message(data) ⇒ Object
- #on_session_start(ws) ⇒ Object
Constructor Details
#initialize(uri, config) ⇒ Server
Returns a new instance of Server.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/drb/websocket/server.rb', line 25 def initialize(uri, config) @uri = uri @config = config @queue = Thread::Queue.new Faye::WebSocket.load_adapter('thin') u = URI.parse(uri) RackApp.register(uri, self) if RackApp.config.standalone Thread.new do app = RackApp.new(-> { [400, {}, []] }) thin = Rack::Handler.get('thin') thin.run(app, Host: u.host, Port: u.port) end.run end end |
Instance Attribute Details
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
23 24 25 |
# File 'lib/drb/websocket/server.rb', line 23 def uri @uri end |
Instance Method Details
#accept ⇒ Object
46 47 48 49 |
# File 'lib/drb/websocket/server.rb', line 46 def accept ws = @queue.pop ServerSide.new(ws, @config, uri) end |
#close ⇒ Object
43 44 |
# File 'lib/drb/websocket/server.rb', line 43 def close end |
#on_message(data) ⇒ Object
51 52 |
# File 'lib/drb/websocket/server.rb', line 51 def (data) end |
#on_session_start(ws) ⇒ Object
54 55 56 |
# File 'lib/drb/websocket/server.rb', line 54 def on_session_start(ws) @queue.push(ws) end |