Something went wrong. Try again.
Modular scanner/radio client and multi-broadcast server. uniscan.dexrn.me
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940using System.Buffers;using Serilog;using UniScan.Device.Connection.Protocol.Payload;
namespace UniScan.Device.Connection.Protocol;
public class PacketReceivedEventArgs<TPayload>(TPayload payload) : EventArgs{ public TPayload Payload { get; } = payload;}
/// <summary>/// Decodes received payloads from the remote scanner for the Connection to use./// </summary>public interface IDeviceProtocol<TPayload>{ /// <summary> /// Fired when a payload has been decoded into a Packet and is ready for handlers to use /// </summary> public event EventHandler<PacketReceivedEventArgs<TPayload>> PacketReceived;
/// <summary> /// Logger for the protocol /// </summary> protected abstract ILogger Logger { get; set; } /// <summary> /// Decodes a payload and fires PacketReceived once usable /// </summary> /// <param name="buffer">The buffer from the remote stream</param> /// <returns>Whether or not the payload was handled successfully, a return value of false may indicate that extra data is required before handling the payload.</returns> bool HandlePayload(ref ReadOnlySequence<byte> buffer);
/// <summary> /// Attempts to skip a payload, used for skipping invalid or unknown data /// </summary> /// <param name="buffer">The buffer from the remote stream</param> /// <returns>Whether skipping was successful</returns> bool TrySkipPayload(ref ReadOnlySequence<byte> buffer);}