From d503b7985807744448504a8b94e4d27110df8e45 Mon Sep 17 00:00:00 2001 From: teascade Date: Wed, 5 Aug 2020 22:02:56 +0300 Subject: [PATCH] Make sure queue works properly and make ShallowCopy for Packet --- Assets/Scripts/Net/CanvasInput.cs | 1 + Assets/Scripts/TeaNet/Packets/Packet.cs | 4 ++++ Assets/Scripts/TeaNet/Peers/ConnectionManager.cs | 1 + 3 files changed, 6 insertions(+) diff --git a/Assets/Scripts/Net/CanvasInput.cs b/Assets/Scripts/Net/CanvasInput.cs index 7e33eb8..3d506d8 100644 --- a/Assets/Scripts/Net/CanvasInput.cs +++ b/Assets/Scripts/Net/CanvasInput.cs @@ -38,6 +38,7 @@ namespace NeonTea.Quakeball.Net { foreach (ulong uid in Net.Singleton.Connections) { HelloPckt pckt = new HelloPckt(); pckt.Text = MessageField.text; + Net.Singleton.Peer.SendReliableLater(uid, pckt); Net.Singleton.Peer.SendReliable(uid, pckt); } } diff --git a/Assets/Scripts/TeaNet/Packets/Packet.cs b/Assets/Scripts/TeaNet/Packets/Packet.cs index c293901..1a28208 100644 --- a/Assets/Scripts/TeaNet/Packets/Packet.cs +++ b/Assets/Scripts/TeaNet/Packets/Packet.cs @@ -15,6 +15,10 @@ namespace NeonTea.Quakeball.TeaNet.Packets { buffer.Write(Id); buffer.Write(Reliable); } + + public Packet ShallowCopy() { + return (Packet)this.MemberwiseClone(); + } } public interface Serializable { diff --git a/Assets/Scripts/TeaNet/Peers/ConnectionManager.cs b/Assets/Scripts/TeaNet/Peers/ConnectionManager.cs index c5007be..325a46f 100644 --- a/Assets/Scripts/TeaNet/Peers/ConnectionManager.cs +++ b/Assets/Scripts/TeaNet/Peers/ConnectionManager.cs @@ -57,6 +57,7 @@ namespace NeonTea.Quakeball.TeaNet.Peers { if (!Connections.ContainsKey(uid)) { return; } + p = p.ShallowCopy(); p.Id = Connections[uid].Internal.ReliablePacketIDCounter++; PacketQueue[uid].Add(p); }