namespace RoboidControl { /// /// Message notifiying that a Thing no longer exists /// public class DestroyMsg : IMessage { /// /// The message ID /// public const byte Id = 0x20; /// /// The length of the message in bytres /// public const byte length = 3; /// /// The network ID of the thing /// public byte networkId; /// /// The ID of the thing /// public byte thingId; /// /// Create a message for sending /// /// The network ID of the thing /// The ID of the thing public DestroyMsg(byte networkId, Thing thing) { this.networkId = networkId; this.thingId = thing.id; } /// @copydoc Passer::RoboidControl::IMessage::IMessage(byte[] buffer) public DestroyMsg(byte[] buffer) : base(buffer) { this.networkId = buffer[1]; this.thingId = buffer[2]; } /// @copydoc Passer::RoboidControl::IMessage::Serialize public override byte Serialize(ref byte[] buffer) { if (buffer.Length < DestroyMsg.length) return 0; #if DEBUG System.Console.WriteLine($"Send DestroyMsg [{this.networkId}/{this.thingId}]"); #endif byte ix = 0; buffer[ix++] = DestroyMsg.Id; buffer[ix++] = this.networkId; buffer[ix++] = this.thingId; return ix; } } }