Class: TacviewClient::Client
- Inherits:
-
Object
- Object
- TacviewClient::Client
- Defined in:
- lib/tacview_client/client.rb
Overview
The actual client to be instantiated to connect to a Tacview Server
Constant Summary collapse
- STREAM_PROTOCOL =
The underlying stream protocol used by Tacview. Needs to be in-sync between the client and the server.
'XtraLib.Stream.0'
- TACVIEW_PROTOCOL =
The application level protocol used by Tacview. Needs to be in-sync between the client and the server.
'Tacview.RealTimeTelemetry.0'
- HANDSHAKE_TERMINATOR =
A null terminator used by Tacview to terminate handshake packages
"\0"
- PASSWORD_HASHER =
Passwords sent between Tacview clients and servers are hashed using this algorithm
CRC['CRC-64-ECMA']
Instance Method Summary collapse
-
#connect ⇒ Object
Connect to the Tacview server.
-
#initialize(host:, port: 42_674, password: nil, processor:, client_name: 'ruby_tacview_client') ⇒ Client
constructor
Returns a new instance of a Client.
Constructor Details
#initialize(host:, port: 42_674, password: nil, processor:, client_name: 'ruby_tacview_client') ⇒ Client
Returns a new instance of a Client
This is the entry point into the gem. Instantiate an instance of this class to setup the prerequisite data for a connection to a Tacview server. Once done call #connect to start processing the Tacview ACMI stream.
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/tacview_client/client.rb', line 40 def initialize(host:, port: 42_674, password: nil, processor:, client_name: 'ruby_tacview_client') @host = host @port = port @password = password @processor = processor @client_name = client_name end |
Instance Method Details
#connect ⇒ Object
Connect to the Tacview server
Actually opens a TCP connection to the Tacview server and starts streaming ACMI lines to an instance of the Reader class.
This method will only return when the TCP connection has be killed either by a client-side signal or by the server closing the TCP connection.
60 61 62 63 64 65 66 67 68 |
# File 'lib/tacview_client/client.rb', line 60 def connect @connection = TCPSocket.open(@host, @port) read_handshake send_handshake start_reader end |