RoboidControl-csharp/Messages/InvestigateMsg.cs
2025-02-19 15:57:44 +01:00

71 lines
2.3 KiB
C#

using System.IO;
using System.Threading.Tasks;
namespace Passer.RoboidControl {
/// <summary>
/// Message to request details for a Thing
/// </summary>
public class InvestigateMsg : IMessage {
/// <summary>
/// The message Id
/// </summary>
public const byte Id = 0x81;
/// <summary>
/// The length of the message
/// </summary>
public const byte length = 3;
/// <summary>
/// The network ID of the thing
/// </summary>
public byte networkId;
/// <summary>
/// The ID of the thing
/// </summary>
public byte thingId;
/// <summary>
/// Create a new message for sending
/// </summary>
/// <param name="networkId">The network ID for the thing</param>
/// <param name="thingId">The ID of the thing</param>
public InvestigateMsg(byte networkId, byte thingId) {
this.networkId = networkId;
this.thingId = thingId;
}
/// @copydoc Passer::RoboidControl::IMessage::IMessage(byte[] buffer)
public InvestigateMsg(byte[] buffer) : base(buffer) { }
/// @copydoc Passer::RoboidControl::IMessage::Serialize
public override byte Serialize(ref byte[] buffer) {
byte ix = 0;
buffer[ix++] = InvestigateMsg.Id;
buffer[ix++] = this.networkId;
buffer[ix++] = this.thingId;
return ix;
}
// public override void Deserialize(byte[] buffer) {
// uint ix = 0;
// this.networkId = buffer[ix++];
// this.thingId = buffer[ix++];
// }
//public static bool Send(Participant client, CoreThing thing) {
// InvestigateMsg msg = new(thing.networkId, thing.id);
// return SendMsg(client, msg);
//}
// public static async Task<bool> Receive(Stream dataStream, Participant client, byte packetSize) {
// if (packetSize != length)
// return false;
// byte[] buffer = await Receive(dataStream, packetSize);
// InvestigateMsg msg = new InvestigateMsg(buffer);
// //UnityEngine.Debug.Log($"Receive investigate [{msg.networkId}/{msg.thingId}]");
// client.messageQueue.Enqueue(msg);
// return true;
// }
}
}