using SilkroadBot.Domain.Enums; namespace SilkroadBot.Domain.Interfaces; /// /// Protocol adapter for a specific game client type/version. /// public interface IProtocolAdapter { /// The client type this adapter supports. GameClientType ClientType { get; } /// Protocol version identifier. string ProtocolVersion { get; } /// Gateway server default port. int GatewayPort { get; } /// Agent server default port. int AgentPort { get; } /// Security initialization bytes for handshake. byte[] GetSecurityInitBytes(); /// Decode a raw packet for this protocol version. PacketDecodeResult DecodePacket(ReadOnlySpan data); /// Encode a packet for sending. byte[] EncodePacket(ushort opcode, byte[] payload, bool encrypted = false); /// Get the opcode mapping for this version. IOpcodeMap GetOpcodeMap(); } /// /// Result of decoding a packet from the wire. /// public record PacketDecodeResult( bool Success, ushort Opcode, byte[] Payload, int BytesConsumed, string? Error = null ); /// /// Maps logical opcodes to protocol-specific values. /// public interface IOpcodeMap { ushort GetOpcode(string logicalName); string GetLogicalName(ushort opcode); bool IsKnownOpcode(ushort opcode); } /// /// Server info for connection. /// public record ServerInfo(string Host, int Port, string Name, GameClientType ClientType);