diff --git a/Unity/SiteServer.cs b/Unity/SiteServer.cs index d428b01..4de91f5 100644 --- a/Unity/SiteServer.cs +++ b/Unity/SiteServer.cs @@ -49,14 +49,13 @@ namespace RoboidControl.Unity { Participant participant = remoteParticipant.AddComponent(); participant.coreParticipant = e.participant; participant.coreParticipant.component = participant; - ParticipantUDP participantUDP = participant.coreParticipant as ParticipantUDP; - if (participantUDP != null) { + if (participant.coreParticipant is ParticipantUDP participantUDP) { participant.ipAddress = participantUDP.ipAddress; participant.port = participantUDP.port; } foreach (RoboidControl.Thing thing in this.site.things) - participant.coreParticipant.SendThingInfo(thing); + participant.coreParticipant.SendThingInfo(thing); break; case ThingMsg.id: diff --git a/src/Messages/PoseMsg.cs b/src/Messages/PoseMsg.cs index 93fd7b9..4b2e70e 100644 --- a/src/Messages/PoseMsg.cs +++ b/src/Messages/PoseMsg.cs @@ -120,7 +120,7 @@ namespace RoboidControl { public override byte Serialize(ref byte[] buffer) { if (poseType == 0) return 0; -#if DEBUG +#if DEBUG2 System.Console.WriteLine($"Send PoseMsg [{this.networkId}/{this.thingId}] {this.poseType}"); #endif diff --git a/src/Participants/ParticipantUDP.cs b/src/Participants/ParticipantUDP.cs index ab4cfa2..860ca65 100644 --- a/src/Participants/ParticipantUDP.cs +++ b/src/Participants/ParticipantUDP.cs @@ -325,12 +325,13 @@ namespace RoboidControl { if (sender == null) { sender = AddParticipant(ipAddress, endPoint.Port, this); sender.isRemote = true; - } - UpdateEvent e = new() { - messageId = NetworkIdMsg.Id, - participant = sender - }; + + UpdateEvent e = new() { + messageId = NetworkIdMsg.Id, + participant = sender + }; + } this.updateQueue.Enqueue(e); ReceiveData(data, sender); @@ -457,6 +458,7 @@ namespace RoboidControl { // Console.Write($"Dropped {thing.id}"); thing.parent = null; } + ForwardMessage(sender, msg); } @@ -479,6 +481,8 @@ namespace RoboidControl { Thing thing = sender.Get(msg.thingId); if (thing != null) thing.name = msg.name; + + ForwardMessage(sender, msg); } protected virtual void Process(Participant sender, ModelUrlMsg msg) { @@ -489,6 +493,8 @@ namespace RoboidControl { Thing thing = sender.Get(msg.thingId); if (thing != null) thing.modelUrl = msg.url; + + ForwardMessage(sender, msg); } protected virtual void Process(Participant sender, PoseMsg msg) { @@ -511,6 +517,8 @@ namespace RoboidControl { thing.linearVelocity = msg.linearVelocity; if ((msg.poseType & PoseMsg.Pose_AngularVelocity) != 0) thing.angularVelocity = msg.angularVelocity; + + ForwardMessage(sender, msg); } protected virtual void Process(Participant sender, BinaryMsg msg) {