Class: KRPC::StreamConnection
- Inherits:
-
Connection
- Object
- Connection
- KRPC::StreamConnection
- Defined in:
- lib/krpc/connection.rb
Overview
TCP connection for streaming.
Constant Summary
Constants inherited from Connection
Connection::DEFAULT_SERVER_HOST, Connection::DEFAULT_SERVER_RPC_PORT, Connection::DEFAULT_SERVER_STREAM_PORT
Instance Attribute Summary collapse
-
#rpc_connection ⇒ Object
readonly
Returns the value of attribute rpc_connection.
Attributes inherited from Connection
Instance Method Summary collapse
-
#handshake ⇒ Object
Perform handshake with kRPC server, sending ‘client_id` retrieved from `rpc_connection`.
-
#initialize(rpc_connection, host = DEFAULT_SERVER_HOST, port = DEFAULT_SERVER_STREAM_PORT) ⇒ StreamConnection
constructor
A new instance of StreamConnection.
Methods inherited from Connection
#cleanup, #close, #connect, #connected?, #protobuf_handshake, #receive_message, #recv, #recv_varint, #send, #send_message
Constructor Details
#initialize(rpc_connection, host = DEFAULT_SERVER_HOST, port = DEFAULT_SERVER_STREAM_PORT) ⇒ StreamConnection
Returns a new instance of StreamConnection.
113 114 115 116 |
# File 'lib/krpc/connection.rb', line 113 def initialize(rpc_connection, host = DEFAULT_SERVER_HOST, port = DEFAULT_SERVER_STREAM_PORT) super host, port @rpc_connection = rpc_connection end |
Instance Attribute Details
#rpc_connection ⇒ Object (readonly)
Returns the value of attribute rpc_connection.
111 112 113 |
# File 'lib/krpc/connection.rb', line 111 def rpc_connection @rpc_connection end |
Instance Method Details
#handshake ⇒ Object
Perform handshake with kRPC server, sending ‘client_id` retrieved from `rpc_connection`.
119 120 121 122 |
# File 'lib/krpc/connection.rb', line 119 def handshake raise(ConnectionError, "RPC connection must obtain client_id before stream connection can perform valid handshake - closing stream connection") if rpc_connection.client_id.nil? protobuf_handshake(:STREAM, client_identifier: rpc_connection.client_id) end |