Class: DRb::WebSocket::ClientSide
- Inherits:
-
Object
- Object
- DRb::WebSocket::ClientSide
- Defined in:
- lib/opal/drb/websocket.rb
Instance Method Summary collapse
- #alive? ⇒ Boolean
- #close ⇒ Object
-
#initialize(uri, config) ⇒ ClientSide
constructor
A new instance of ClientSide.
- #recv_reply(reply_stream) ⇒ Object
- #send(uri, data) ⇒ Object
- #send_request(ref, msg_id, *arg, &b) ⇒ Object
Constructor Details
#initialize(uri, config) ⇒ ClientSide
Returns a new instance of ClientSide.
256 257 258 259 260 261 262 |
# File 'lib/opal/drb/websocket.rb', line 256 def initialize(uri, config) @uri = uri @pool = SocketPool.open(uri) @res = nil @config = config @msg = DRbMessage.new(@config) end |
Instance Method Details
#alive? ⇒ Boolean
264 265 266 |
# File 'lib/opal/drb/websocket.rb', line 264 def alive? !!@pool.ws && @pool.ws.open? end |
#close ⇒ Object
268 269 |
# File 'lib/opal/drb/websocket.rb', line 268 def close end |
#recv_reply(reply_stream) ⇒ Object
277 278 279 |
# File 'lib/opal/drb/websocket.rb', line 277 def recv_reply(reply_stream) @msg.recv_reply(reply_stream) end |
#send(uri, data) ⇒ Object
281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
# File 'lib/opal/drb/websocket.rb', line 281 def send(uri, data) promise = Promise.new @pool.send(data) do || reply_stream = StrStream.new reply_stream.write(.to_s) if @config[:load_limit] < reply_stream.buf.size raise TypeError, 'too large packet' end promise.resolve reply_stream end promise end |