Пример #1
0
        public static Dictionary <short, NetworkConnection.PacketStat> GetTotalConnectionStats()
        {
            Dictionary <short, NetworkConnection.PacketStat> dictionary = new Dictionary <short, NetworkConnection.PacketStat>();

            for (int i = 0; i < NetworkClient.s_Clients.Count; i++)
            {
                NetworkClient networkClient = NetworkClient.s_Clients[i];
                Dictionary <short, NetworkConnection.PacketStat> connectionStats = networkClient.GetConnectionStats();
                foreach (short key in connectionStats.Keys)
                {
                    if (dictionary.ContainsKey(key))
                    {
                        NetworkConnection.PacketStat packetStat = dictionary[key];
                        packetStat.count += connectionStats[key].count;
                        packetStat.bytes += connectionStats[key].bytes;
                        dictionary[key]   = packetStat;
                    }
                    else
                    {
                        dictionary[key] = new NetworkConnection.PacketStat(connectionStats[key]);
                    }
                }
            }
            return(dictionary);
        }