using System.IO;
using System.Threading.Tasks;
namespace Passer.RoboidControl {
///
/// Message to request details for a Thing
///
public class InvestigateMsg : IMessage {
///
/// The message Id
///
public const byte Id = 0x81;
///
/// The length of the message
///
public const byte length = 3;
///
/// The network ID of the thing
///
public byte networkId;
///
/// The ID of the thing
///
public byte thingId;
///
/// Create a new message for sending
///
/// The network ID for the thing
/// The ID of the thing
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 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;
// }
}
}