diff --git a/Runtime/HumanoidControl/Scripts/Networking/Roboid/ControlCore/Client.cs b/Runtime/HumanoidControl/Scripts/Networking/Roboid/ControlCore/Client.cs index 26ad994..e54583e 100644 --- a/Runtime/HumanoidControl/Scripts/Networking/Roboid/ControlCore/Client.cs +++ b/Runtime/HumanoidControl/Scripts/Networking/Roboid/ControlCore/Client.cs @@ -47,6 +47,7 @@ namespace Passer.Control { ProcessNetworkId(networkId); break; case InvestigateMsg investigate: + UnityEngine.Debug.Log($"investigate [{investigate.networkId}/{investigate.thingId}]"); ProcessInvestigate(investigate); break; case ThingMsg thing: @@ -96,11 +97,12 @@ namespace Passer.Control { protected virtual void ProcessDestroy(DestroyMsg destroy) { } - private void ForwardMessage(IMessage thing) { + private void ForwardMessage(IMessage msg) { foreach (Client client in Client.clients) { if (client == this) continue; - IMessage.SendMsg(client, thing); + UnityEngine.Debug.Log($"---> {client.ipAddress}"); + IMessage.SendMsg(client, msg); } } } diff --git a/Runtime/HumanoidControl/Scripts/Networking/Roboid/ControlCore/Messages.cs b/Runtime/HumanoidControl/Scripts/Networking/Roboid/ControlCore/Messages.cs index fece487..c0e852b 100644 --- a/Runtime/HumanoidControl/Scripts/Networking/Roboid/ControlCore/Messages.cs +++ b/Runtime/HumanoidControl/Scripts/Networking/Roboid/ControlCore/Messages.cs @@ -19,6 +19,7 @@ namespace Passer.Control { if (client == null || client.ipAddress == null) return false; + //UnityEngine.Debug.Log($"Send msg {buffer[0]} to {client.ipAddress}"); client.udpClient.Send(buffer, buffer.Length, client.ipAddress, client.port); return true; } @@ -232,6 +233,10 @@ namespace Passer.Control { byte[] buffer = await Receive(dataStream, packetSize); ThingMsg msg = new(buffer); + // Do no process poses with nwid == 0 (== local) + if (msg.networkId == 0) + return true; + client.messageQueue.Enqueue(msg); return true; } @@ -412,6 +417,10 @@ namespace Passer.Control { byte[] buffer = await Receive(dataStream, packetSize); PoseMsg msg = new(buffer); + // Do no process poses with nwid == 0 (== local) + if (msg.networkId == 0) + return true; + client.messageQueue.Enqueue(msg); return true; } @@ -435,25 +444,25 @@ namespace Passer.Control { } public override byte[] Serialize() { - byte[] buffer = new byte[4 + this.bytes.Length]; + byte[] buffer = new byte[3 + this.bytes.Length]; byte ix = 0; buffer[ix++] = CustomMsg.Id; buffer[ix++] = this.networkId; buffer[ix++] = this.thingId; - buffer[ix++] = (byte)bytes.Length; + //buffer[ix++] = (byte)bytes.Length; foreach (byte b in bytes) buffer[ix++] = b; return buffer; } public override void Deserialize(byte[] buffer) { - uint ix = 0; + byte ix = 0; this.networkId = buffer[ix++]; this.thingId = buffer[ix++]; - byte length = buffer[ix++]; + byte length = (byte)(buffer.Length - ix);//buffer[ix++]; this.bytes = new byte[length]; - for (uint bytesIx = 0; ix < length; ix++, bytesIx++) - this.bytes[bytesIx] = buffer[ix]; + for (uint bytesIx = 0; bytesIx < length; bytesIx++) + this.bytes[bytesIx] = buffer[ix++]; } public static void Send(Client client, byte thingId, byte[] bytes) { diff --git a/Runtime/HumanoidControl/Scripts/Networking/Roboid/ControlCore/SiteServer.cs b/Runtime/HumanoidControl/Scripts/Networking/Roboid/ControlCore/SiteServer.cs index a563bf5..57460f3 100644 --- a/Runtime/HumanoidControl/Scripts/Networking/Roboid/ControlCore/SiteServer.cs +++ b/Runtime/HumanoidControl/Scripts/Networking/Roboid/ControlCore/SiteServer.cs @@ -21,6 +21,7 @@ namespace Passer.Control { return; } + //UnityEngine.Debug.Log($"R {msgId} from {client.ipAddress}"); bool result = false; switch (msgId) { case ClientMsg.Id: // 0xA0 / 160