namespace RoboidControl { /// /// Message for communicating the URL for a model of the thing /// public class ModelUrlMsg : IMessage { /// /// The message ID /// public const byte Id = 0x90; // (144) Model URL /// /// The length of the message without th URL itself /// public const byte length = 4; /// /// The network ID of the thing /// public byte networkId; /// /// The ID of the thing /// public byte thingId; /// /// The URL of the model /// public string url = null; /// /// Create a new message for sending /// /// The network ID of the thing /// The thing for which to send the model URL public ModelUrlMsg(byte networkId, Thing thing) { this.networkId = networkId; this.thingId = thing.id; this.url = thing.modelUrl; } /// /// Create a new message for sending /// /// The network ID of the thing /// The ID of the thing /// The URL to send public ModelUrlMsg(byte networkId, byte thingId, string url) { this.networkId = networkId; this.thingId = thingId; this.url = url; } /// @copydoc Passer::RoboidControl::IMessage::IMessage(byte[] buffer) public ModelUrlMsg(byte[] buffer) { byte ix = 1; this.networkId = buffer[ix++]; this.thingId = buffer[ix++]; int strlen = buffer[ix++]; url = System.Text.Encoding.UTF8.GetString(buffer, (int)ix, strlen); } /// @copydoc Passer::RoboidControl::IMessage::Serialize public override byte Serialize(ref byte[] buffer) { if (this.url == null) return 0; byte ix = 0; buffer[ix++] = ModelUrlMsg.Id; buffer[ix++] = this.networkId; buffer[ix++] = this.thingId; // Thing Id buffer[ix++] = (byte)this.url.Length; for (int urlIx = 0; urlIx < this.url.Length; urlIx++) buffer[ix++] = (byte)url[urlIx]; return ix; } } }