Class: KRPC::RPCConnection
- Inherits:
-
Connection
- Object
- Connection
- KRPC::RPCConnection
- Defined in:
- lib/krpc/connection.rb
Overview
TCP connection for sending RPC calls and retrieving it’s 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
Clean up - sets ‘@client_id` to `nil`.
-
#handshake ⇒ Object
Perform handshake with kRPC server, obtaining ‘@client_id`.
-
#initialize(name, host = DEFAULT_SERVER_HOST, port = DEFAULT_SERVER_RPC_PORT) ⇒ RPCConnection
constructor
A new instance of RPCConnection.
Methods inherited from Connection
#close, #connect, #connected?, #recv, #recv_varint, #send
Constructor Details
#initialize(name, host = DEFAULT_SERVER_HOST, port = DEFAULT_SERVER_RPC_PORT) ⇒ RPCConnection
Returns a new instance of RPCConnection.
82 83 84 85 |
# File 'lib/krpc/connection.rb', line 82 def initialize(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.
80 81 82 |
# File 'lib/krpc/connection.rb', line 80 def client_id @client_id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
80 81 82 |
# File 'lib/krpc/connection.rb', line 80 def name @name end |
Instance Method Details
#cleanup ⇒ Object
Clean up - sets ‘@client_id` to `nil`.
95 96 97 |
# File 'lib/krpc/connection.rb', line 95 def cleanup @client_id = nil end |
#handshake ⇒ Object
Perform handshake with kRPC server, obtaining ‘@client_id`.
88 89 90 91 92 |
# File 'lib/krpc/connection.rb', line 88 def handshake send Encoder::RPC_HELLO_MESSAGE send trim_fill(name, Encoder::NAME_LENGTH) @client_id = recv Decoder::GUID_LENGTH end |