From 6e5b923f978c3ba72acd1575c5e1f5e4792b9e8b Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Mon, 9 Dec 2024 17:13:38 +0100 Subject: [PATCH] Add networkId to msg constructors --- Messages.cs | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/Messages.cs b/Messages.cs index 5a6c43d..a24554f 100644 --- a/Messages.cs +++ b/Messages.cs @@ -196,7 +196,7 @@ namespace Passer.Control { public byte thingType; public byte parentId; - public ThingMsg(byte thingId, byte thingType, byte parentId) { + public ThingMsg(byte networkId, byte thingId, byte thingType, byte parentId) { this.thingId = thingId; this.thingType = thingType; this.parentId = parentId; @@ -222,7 +222,7 @@ namespace Passer.Control { } public static bool Send(Client client, byte thingId, byte thingType, byte parentId) { - ThingMsg msg = new(thingId, thingType, parentId); + ThingMsg msg = new(client.networkId, thingId, thingType, parentId); return SendMsg(client, msg); } public static async Task Receive(Stream dataStream, Client client, byte packetSize) { @@ -249,7 +249,8 @@ namespace Passer.Control { public byte len; public string name; - public NameMsg(byte thingId, string name) { + public NameMsg(byte networkId, byte thingId, string name) { + this.networkId = networkId; this.thingId = thingId; this.name = name; } @@ -274,7 +275,7 @@ namespace Passer.Control { } public static bool Send(Client client, byte thingId, string name) { - NameMsg msg = new(thingId, name); + NameMsg msg = new(client.networkId, thingId, name); return SendMsg(client, msg); } public static async Task Receive(Stream dataStream, Client client, byte packetSize) { @@ -298,7 +299,8 @@ namespace Passer.Control { public float scale; public string url; - public ModelUrlMsg(byte thingId, string url, float scale = 1) { + public ModelUrlMsg(byte networkId, byte thingId, string url, float scale = 1) { + this.networkId = networkId; this.thingId = thingId; this.url = url; this.scale = scale; @@ -329,7 +331,7 @@ namespace Passer.Control { } public static bool Send(Client client, byte thingId, string modelUrl) { - ModelUrlMsg msg = new(thingId, modelUrl); + ModelUrlMsg msg = new(client.networkId, thingId, modelUrl); return SendMsg(client, msg); } public static async Task Receive(Stream dataStream, Client client, byte packetSize) { @@ -357,7 +359,8 @@ namespace Passer.Control { public Spherical position; public Quat32 orientation; - public PoseMsg(byte thingId, Spherical position, Quat32 orientation) { + public PoseMsg(byte networkId, byte thingId, Spherical position, Quat32 orientation) { + this.networkId = networkId; this.thingId = thingId; this.position = position; this.orientation = orientation; @@ -381,24 +384,24 @@ namespace Passer.Control { buffer[ix++] = this.thingId; buffer[ix++] = this.poseType; - LowLevelMessages.SendSpherical(buffer, ref ix, position); - LowLevelMessages.SendQuat32(buffer, ref ix, orientation); + LowLevelMessages.SendSpherical(buffer, ref ix, this.position); + LowLevelMessages.SendQuat32(buffer, ref ix, this.orientation); return buffer; } public override void Deserialize(byte[] buffer) { byte ix = 0; - thingId = buffer[ix++]; - thingId = buffer[ix++]; - poseType = buffer[ix++]; + this.networkId = buffer[ix++]; + this.thingId = buffer[ix++]; + this.poseType = buffer[ix++]; //if ((poseType & Pose_Position) != 0) - position = LowLevelMessages.ReceiveSpherical(buffer, ref ix); + this.position = LowLevelMessages.ReceiveSpherical(buffer, ref ix); //if ((poseType & Pose_Orientation) != 0) { - orientation = LowLevelMessages.ReceiveQuat32(buffer, ref ix); + this.orientation = LowLevelMessages.ReceiveQuat32(buffer, ref ix); } public static bool Send(Client client, byte thingId, Spherical position, Quat32 orientation) { - PoseMsg msg = new(thingId, position, orientation); + PoseMsg msg = new(client.networkId, thingId, position, orientation); return SendMsg(client, msg); } public static async Task Receive(Stream dataStream, Client client, byte packetSize) {