Class: KRPC::RPCConnection
- Inherits:
-
Connection
- Object
- Connection
- KRPC::RPCConnection
- Defined in:
- lib/krpc/connection.rb
Overview
TCP connection for sending RPC calls and retrieving its results.
Constant Summary
Constants inherited from Connection
Connection::DEFAULT_SERVER_HOST, Connection::DEFAULT_SERVER_RPC_PORT, Connection::DEFAULT_SERVER_STREAM_PORT
Instance Attribute Summary collapse
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from Connection
Instance Method Summary collapse
- #cleanup ⇒ Object
-
#handshake ⇒ Object
Perform handshake with kRPC server, obtaining ‘@client_id`.
-
#initialize(name = Client::DEFAULT_NAME, host = DEFAULT_SERVER_HOST, port = DEFAULT_SERVER_RPC_PORT) ⇒ RPCConnection
constructor
A new instance of RPCConnection.
Methods inherited from Connection
#close, #connect, #connected?, #protobuf_handshake, #receive_message, #recv, #recv_varint, #send, #send_message
Constructor Details
#initialize(name = Client::DEFAULT_NAME, host = DEFAULT_SERVER_HOST, port = DEFAULT_SERVER_RPC_PORT) ⇒ RPCConnection
Returns a new instance of RPCConnection.
92 93 94 95 |
# File 'lib/krpc/connection.rb', line 92 def initialize(name = Client::DEFAULT_NAME, host = DEFAULT_SERVER_HOST, port = DEFAULT_SERVER_RPC_PORT) super host, port @name = name end |
Instance Attribute Details
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
90 91 92 |
# File 'lib/krpc/connection.rb', line 90 def client_id @client_id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
90 91 92 |
# File 'lib/krpc/connection.rb', line 90 def name @name end |
Instance Method Details
#cleanup ⇒ Object
103 104 105 |
# File 'lib/krpc/connection.rb', line 103 def cleanup @client_id = nil end |
#handshake ⇒ Object
Perform handshake with kRPC server, obtaining ‘@client_id`.
98 99 100 101 |
# File 'lib/krpc/connection.rb', line 98 def handshake resp = protobuf_handshake(:RPC, client_name: name) @client_id = resp.client_identifier end |