Class: DRbWebSocket::ConnectionToClient

Inherits:
Object
  • Object
show all
Defined in:
lib/drb_web_socket/connection_to_client.rb

Overview

A connection instance from DrbWebSocket::Server#accept.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#uriObject (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

#closeObject

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_requestObject

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