Class: TunnelRb::Server::Client
- Inherits:
-
Object
- Object
- TunnelRb::Server::Client
- Defined in:
- lib/tunnel_rb/server/client.rb
Overview
Server-side view of a connected tunnel client. Owns the control socket and per-connection state (read buffer, ping bookkeeping, write mutex).
Instance Attribute Summary collapse
-
#missed_pongs ⇒ Object
Returns the value of attribute missed_pongs.
-
#pong_received ⇒ Object
Returns the value of attribute pong_received.
-
#read_buffer ⇒ Object
readonly
Returns the value of attribute read_buffer.
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
-
#subdomain ⇒ Object
readonly
Returns the value of attribute subdomain.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize(subdomain:, socket:, token:) ⇒ Client
constructor
A new instance of Client.
- #send_message(payload) ⇒ Object
Constructor Details
#initialize(subdomain:, socket:, token:) ⇒ Client
Returns a new instance of Client.
14 15 16 17 18 19 20 21 22 |
# File 'lib/tunnel_rb/server/client.rb', line 14 def initialize(subdomain:, socket:, token:) @subdomain = subdomain @socket = socket @token = token @write_mutex = Mutex.new @read_buffer = String.new(encoding: Encoding::ASCII_8BIT) @missed_pongs = 0 @pong_received = true end |
Instance Attribute Details
#missed_pongs ⇒ Object
Returns the value of attribute missed_pongs.
12 13 14 |
# File 'lib/tunnel_rb/server/client.rb', line 12 def missed_pongs @missed_pongs end |
#pong_received ⇒ Object
Returns the value of attribute pong_received.
12 13 14 |
# File 'lib/tunnel_rb/server/client.rb', line 12 def pong_received @pong_received end |
#read_buffer ⇒ Object (readonly)
Returns the value of attribute read_buffer.
11 12 13 |
# File 'lib/tunnel_rb/server/client.rb', line 11 def read_buffer @read_buffer end |
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
11 12 13 |
# File 'lib/tunnel_rb/server/client.rb', line 11 def socket @socket end |
#subdomain ⇒ Object (readonly)
Returns the value of attribute subdomain.
11 12 13 |
# File 'lib/tunnel_rb/server/client.rb', line 11 def subdomain @subdomain end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
11 12 13 |
# File 'lib/tunnel_rb/server/client.rb', line 11 def token @token end |
Instance Method Details
#send_message(payload) ⇒ Object
24 25 26 |
# File 'lib/tunnel_rb/server/client.rb', line 24 def (payload) @write_mutex.synchronize { @socket.puts(payload.to_json) } end |