diff --git a/Assets/Scripts/TeaNet/Peers/ConnectionManager.cs b/Assets/Scripts/TeaNet/Peers/ConnectionManager.cs index 7a0b8f2..a9e5212 100644 --- a/Assets/Scripts/TeaNet/Peers/ConnectionManager.cs +++ b/Assets/Scripts/TeaNet/Peers/ConnectionManager.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Collections.Concurrent; using System.Net; using System.Threading; using System; @@ -23,8 +24,8 @@ namespace NeonTea.Quakeball.TeaNet.Peers { /// The amount of bytes sent since the last clear interval from Peer public int BytesSent; - public Dictionary SentByPacket = new Dictionary(); - public Dictionary ReceivedByPacket = new Dictionary(); + public ConcurrentDictionary SentByPacket = new ConcurrentDictionary(); + public ConcurrentDictionary ReceivedByPacket = new ConcurrentDictionary(); public ConnectionManager(Peer peer) { Peer = peer; diff --git a/Assets/Scripts/TeaNet/Peers/Peer.cs b/Assets/Scripts/TeaNet/Peers/Peer.cs index c6fc7a0..20c72c4 100644 --- a/Assets/Scripts/TeaNet/Peers/Peer.cs +++ b/Assets/Scripts/TeaNet/Peers/Peer.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Collections.Concurrent; using System; using System.Net; using System.Net.Sockets; @@ -30,16 +31,16 @@ namespace NeonTea.Quakeball.TeaNet.Peers { ConnectionManager.Interval = value; } } - /// The interval of traffic analyzed before updating - public long TrafficDataInterval = 1000; + /// The interval of traffic analyzed before updating. By default 5000 (5 seconds) + public long TrafficDataInterval = 5000; /// The amount of bytes received in the last TrafficDataIntervel public int TrafficReceived { get; private set; } /// The amount of bytes sent in the last TrafficDataIntervel public int TrafficSent { get; private set; } /// The amount of bytes sent in the last TrafficDataIntervel by Packet - public Dictionary TrafficSentByPacket => ConnectionManager.SentByPacket; + public ConcurrentDictionary TrafficSentByPacket => ConnectionManager.SentByPacket; /// The amount of bytes received in the last TrafficDataIntervel by Packet - public Dictionary TrafficReceivedByPacket => ConnectionManager.ReceivedByPacket; + public ConcurrentDictionary TrafficReceivedByPacket => ConnectionManager.ReceivedByPacket; /// Whether the Peer is currently doing anything or not.null public bool Running { get; private set; }