Class: DRbWebSocket::ConnectionToServer
- Inherits:
-
Object
- Object
- DRbWebSocket::ConnectionToServer
- Defined in:
- lib/drb_web_socket/connection_to_server.rb
Overview
A protocol instance from DrbWebSocket::Protocol.open.
Instance Method Summary collapse
-
#alive? ⇒ Boolean
Is this connection still alive?.
-
#close ⇒ Object
Close this connection.
-
#initialize(uri, socket, config = {}) ⇒ ConnectionToServer
constructor
A new instance of ConnectionToServer.
-
#recv_reply ⇒ Object
Receive a reply from the server and return it as a [success-boolean, reply-value] pair.
-
#send_request(ref, msg_id, arg, block) ⇒ Object
Send a request to
ref
with the given message id and arguments.
Constructor Details
#initialize(uri, socket, config = {}) ⇒ ConnectionToServer
Returns a new instance of ConnectionToServer.
8 9 10 11 12 13 |
# File 'lib/drb_web_socket/connection_to_server.rb', line 8 def initialize(uri, socket, config = {}) @uri = uri @socket = socket @config = config @msg = DRb::DRbMessage.new(config) end |
Instance Method Details
#alive? ⇒ Boolean
Is this connection still alive?
34 35 36 37 38 |
# File 'lib/drb_web_socket/connection_to_server.rb', line 34 def alive? return false unless @socket true end |
#close ⇒ Object
Close this connection.
26 27 28 29 30 31 |
# File 'lib/drb_web_socket/connection_to_server.rb', line 26 def close return unless @socket @socket.close @socket = nil end |
#recv_reply ⇒ Object
Receive a reply from the server and return it as a [success-boolean, reply-value] pair.
21 22 23 |
# File 'lib/drb_web_socket/connection_to_server.rb', line 21 def recv_reply @msg.recv_reply(@socket) end |
#send_request(ref, msg_id, arg, block) ⇒ Object
Send a request to ref
with the given message id and arguments.
16 17 18 |
# File 'lib/drb_web_socket/connection_to_server.rb', line 16 def send_request(ref, msg_id, arg, block) @msg.send_request(@socket, ref, msg_id, arg, block) end |