Class: DRbWebSocket::ConnectionToClient
- Inherits:
-
Object
- Object
- DRbWebSocket::ConnectionToClient
- Defined in:
- lib/drb_web_socket/connection_to_client.rb
Overview
A connection instance from DrbWebSocket::Server#accept.
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
DRb::DRbServer#main_loop calls
client.urimethod.
Instance Method Summary collapse
-
#close ⇒ Object
Close this connection.
-
#initialize(uri, socket, config = {}) ⇒ ConnectionToClient
constructor
A new instance of ConnectionToClient.
-
#recv_request ⇒ Object
Receive a request from the client and return a [object, message, args, block] tuple.
-
#send_reply(succ, result) ⇒ Object
Send a reply to the client.
Constructor Details
#initialize(uri, socket, config = {}) ⇒ ConnectionToClient
Returns a new instance of ConnectionToClient.
9 10 11 12 13 14 |
# File 'lib/drb_web_socket/connection_to_client.rb', line 9 def initialize(uri, socket, config = {}) @uri = uri @socket = socket @config = config @msg = DRb::DRbMessage.new(config) end |
Instance Attribute Details
#uri ⇒ Object (readonly)
DRb::DRbServer#main_loop calls client.uri method.
7 8 9 |
# File 'lib/drb_web_socket/connection_to_client.rb', line 7 def uri @uri end |
Instance Method Details
#close ⇒ Object
Close this connection.
27 28 29 30 31 32 |
# File 'lib/drb_web_socket/connection_to_client.rb', line 27 def close return unless @socket @socket.close @socket = nil end |
#recv_request ⇒ Object
Receive a request from the client and return a [object, message, args, block] tuple.
17 18 19 |
# File 'lib/drb_web_socket/connection_to_client.rb', line 17 def recv_request @msg.recv_request(@socket) end |
#send_reply(succ, result) ⇒ Object
Send a reply to the client.
22 23 24 |
# File 'lib/drb_web_socket/connection_to_client.rb', line 22 def send_reply(succ, result) @msg.send_reply(@socket, succ, result) end |