Class: DRb::WebSocket::Server
- Inherits:
-
Object
- Object
- DRb::WebSocket::Server
- Defined in:
- lib/opal/drb/websocket.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.
Constructor Details
#initialize(uri, config) ⇒ Server
Returns a new instance of Server.
102 103 104 105 |
# File 'lib/opal/drb/websocket.rb', line 102 def initialize(uri, config) @uri = "#{uri}/#{SecureRandom.uuid}" @config = config end |
Instance Attribute Details
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
100 101 102 |
# File 'lib/opal/drb/websocket.rb', line 100 def uri @uri end |
Instance Method Details
#accept ⇒ Object
111 112 113 114 115 116 117 118 119 |
# File 'lib/opal/drb/websocket.rb', line 111 def accept ws = ::WebSocket.new(@uri) ws. do |event| stream = StrStream.new(event.data.to_s) server_side = ServerSide.new(stream, @config, uri) yield server_side ws.send(`new Uint8Array(#{server_side.reply.bytes.each_slice(2).map(&:first)}).buffer`) end end |
#close ⇒ Object
107 108 109 |
# File 'lib/opal/drb/websocket.rb', line 107 def close @ws.close end |