Change ByPacket traffic to ConcurrentDictionary

This commit is contained in:
Sofia 2020-08-10 21:02:41 +03:00
parent 069de32c29
commit e5a1ade875
2 changed files with 8 additions and 6 deletions

View File

@ -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 {
/// <summary>The amount of bytes sent since the last clear interval from Peer</summary>
public int BytesSent;
public Dictionary<Type, int> SentByPacket = new Dictionary<Type, int>();
public Dictionary<Type, int> ReceivedByPacket = new Dictionary<Type, int>();
public ConcurrentDictionary<Type, int> SentByPacket = new ConcurrentDictionary<Type, int>();
public ConcurrentDictionary<Type, int> ReceivedByPacket = new ConcurrentDictionary<Type, int>();
public ConnectionManager(Peer peer) {
Peer = peer;

View File

@ -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;
}
}
/// <summary>The interval of traffic analyzed before updating</summary>
public long TrafficDataInterval = 1000;
/// <summary>The interval of traffic analyzed before updating. By default 5000 (5 seconds)</summary>
public long TrafficDataInterval = 5000;
/// <summary>The amount of bytes received in the last TrafficDataIntervel</summary>
public int TrafficReceived { get; private set; }
/// <summary>The amount of bytes sent in the last TrafficDataIntervel</summary>
public int TrafficSent { get; private set; }
/// <summary>The amount of bytes sent in the last TrafficDataIntervel by Packet</summary>
public Dictionary<Type, int> TrafficSentByPacket => ConnectionManager.SentByPacket;
public ConcurrentDictionary<Type, int> TrafficSentByPacket => ConnectionManager.SentByPacket;
/// <summary>The amount of bytes received in the last TrafficDataIntervel by Packet</summary>
public Dictionary<Type, int> TrafficReceivedByPacket => ConnectionManager.ReceivedByPacket;
public ConcurrentDictionary<Type, int> TrafficReceivedByPacket => ConnectionManager.ReceivedByPacket;
/// <summary>Whether the Peer is currently doing anything or not.null</sumary>
public bool Running { get; private set; }