Class: Cosmos::FixedStreamProtocol
- Inherits:
-
StreamProtocol
- Object
- StreamProtocol
- Cosmos::FixedStreamProtocol
- Defined in:
- lib/cosmos/streams/fixed_stream_protocol.rb
Overview
This StreamProtocol delineates packets by identifying them and then reading out their entire fixed length. Packets lengths can vary but they must all be fixed.
Instance Attribute Summary
Attributes inherited from StreamProtocol
#bytes_read, #bytes_written, #interface, #post_read_data_callback, #post_read_packet_callback, #post_write_data_callback, #pre_write_packet_callback, #stream
Instance Method Summary collapse
-
#initialize(min_id_size, discard_leading_bytes = 0, sync_pattern = nil, telemetry_stream = true, fill_sync_pattern = false) ⇒ FixedStreamProtocol
constructor
A new instance of FixedStreamProtocol.
-
#post_read_packet(packet) ⇒ Object
Set the received_time, target_name and packet_name which we recorded when we identified this packet.
Methods inherited from StreamProtocol
#connect, #connected?, #disconnect, #post_read_data, #post_write_data, #pre_write_packet, #read, #write, #write_raw
Constructor Details
#initialize(min_id_size, discard_leading_bytes = 0, sync_pattern = nil, telemetry_stream = true, fill_sync_pattern = false) ⇒ FixedStreamProtocol
Returns a new instance of FixedStreamProtocol.
28 29 30 31 32 33 34 35 36 |
# File 'lib/cosmos/streams/fixed_stream_protocol.rb', line 28 def initialize(min_id_size, discard_leading_bytes = 0, sync_pattern = nil, telemetry_stream = true, fill_sync_pattern = false) super(discard_leading_bytes, sync_pattern, fill_sync_pattern) @min_id_size = Integer(min_id_size) @telemetry_stream = telemetry_stream end |
Instance Method Details
#post_read_packet(packet) ⇒ Object
Set the received_time, target_name and packet_name which we recorded when we identified this packet. The server will also do this but since we know the information here, we perform this optimization. See StreamProtocol#post_read_packet
42 43 44 45 46 47 |
# File 'lib/cosmos/streams/fixed_stream_protocol.rb', line 42 def post_read_packet(packet) packet.received_time = @received_time packet.target_name = @target_name packet.packet_name = @packet_name packet end |