diff --git a/Bundler/Viewer/Unity/Assets/Scripts/Network/Scripts/GenericNetworkTransmitter.cs b/Bundler/Viewer/Unity/Assets/Scripts/Network/Scripts/GenericNetworkTransmitter.cs index 45118157..4b7fd73f 100644 --- a/Bundler/Viewer/Unity/Assets/Scripts/Network/Scripts/GenericNetworkTransmitter.cs +++ b/Bundler/Viewer/Unity/Assets/Scripts/Network/Scripts/GenericNetworkTransmitter.cs @@ -77,6 +77,14 @@ public class GenericNetworkTransmitter StartAsClient(serverIp); } + /// + /// Stop any pending sends or requests + /// + public void StopAll() + { + StopServerAndClient(); + } + // A lot of the work done in this class can only be done in UWP. The editor is not a UWP app. #if !UNITY_EDITOR /// @@ -109,6 +117,15 @@ public class GenericNetworkTransmitter /// private const int timeToDeferFailedConnectionsMS = 3000; + /// + /// Stop the server and client request.s + /// + private async void StopServerAndClient() + { + StopClient(); + await StopServer(); + } + /// /// Stop the current server /// @@ -371,7 +388,11 @@ public class GenericNetworkTransmitter return await task; } #else - public void StartAsServer(byte[] data) + private void StopServerAndClient() + { + } + + private void StartAsServer(byte[] data) { } diff --git a/Bundler/Viewer/Unity/Assets/Scripts/Network/Scripts/MyNetworkAnchorClient.cs b/Bundler/Viewer/Unity/Assets/Scripts/Network/Scripts/MyNetworkAnchorClient.cs index 351d9a71..4bbe9657 100644 --- a/Bundler/Viewer/Unity/Assets/Scripts/Network/Scripts/MyNetworkAnchorClient.cs +++ b/Bundler/Viewer/Unity/Assets/Scripts/Network/Scripts/MyNetworkAnchorClient.cs @@ -151,7 +151,16 @@ public class MyNetworkAnchorClient : NetworkBehaviour // The last received anchor will no longer be relevant since we're taking ownership LastRecievedAnchor = null; + // Stop all pending work on the anchor transmitter + anchorTransmitter.StopAll(); + // Start taking ownership of the anchor + SharedAnchorData anchorSource; + anchorSource.SourceIp = LocalAddress; + anchorSource.AnchorId = anchorId; + CmdSetAnchorSource(anchorSource); + + // Export binary data List buffer = new List(); WorldAnchorTransferBatch batch = new WorldAnchorTransferBatch(); batch.AddWorldAnchor(anchorId, worldAnchor); @@ -230,11 +239,11 @@ public class MyNetworkAnchorClient : NetworkBehaviour { Debug.LogFormat("[MyNetworkAnchorClient] Exporting anchor succeeded: {0} ({1} bytes)", anchorId, data.Length); - SharedAnchorData anchorSource; - anchorSource.SourceIp = LocalAddress; - anchorSource.AnchorId = anchorId; + //SharedAnchorData anchorSource; + //anchorSource.SourceIp = LocalAddress; + //anchorSource.AnchorId = anchorId; anchorTransmitter.SendData(data); - CmdSetAnchorSource(anchorSource); + //CmdSetAnchorSource(anchorSource); } else {