예제 #1
0
    void Update()
    {
        if (Time.time <= statTimer)
        {
            return;
        }

        statTimer = Time.time + 1;

        if (NetworkClient.allClients.Count > 0)
        {
            Dictionary <short, NetworkConnection.PacketStat> stats = NetworkClient.allClients[0].GetConnectionStats();
            if (stats != null)
            {
                foreach (var stat in stats.Values)
                {
                    if (stat.count > 0)
                    {
                        if (!packetStats.ContainsKey(stat.msgType))
                        {
                            packetStats[stat.msgType] = new PacketStatInfo(stat.msgType);
                        }
                        packetStats[stat.msgType].Add(stat);
                    }
                }
                NetworkClient.allClients[0].ResetConnectionStats();
            }
        }

        if (NetworkServer.active)
        {
            Dictionary <short, NetworkConnection.PacketStat> stats = NetworkServer.GetConnectionStats();
            if (stats != null)
            {
                foreach (var stat in stats.Values)
                {
                    if (stat.count > 0)
                    {
                        if (!packetStats.ContainsKey(stat.msgType))
                        {
                            packetStats[stat.msgType] = new PacketStatInfo(stat.msgType);
                        }
                        packetStats[stat.msgType].Add(stat);
                    }
                }
                NetworkServer.ResetConnectionStats();
            }
        }
    }