Esempio n. 1
0
        static WebStats()
        {
            CMOptions = new WebStatsOptions();

            Snapshot = new Dictionary <IPAddress, List <Mobile> >();

            Stats = new BinaryDataStore <string, WebStatsEntry>(VitaNexCore.SavesDirectory + "/WebStats", "Stats")
            {
                Async         = true,
                OnSerialize   = SerializeStats,
                OnDeserialize = DeserializeStats
            };

            _Json = new Dictionary <string, object>();

            var uptime = VitaNexCore.UpTime;

            Stats["uptime"]      = new WebStatsEntry(uptime, false);
            Stats["uptime_peak"] = new WebStatsEntry(uptime, true);

            Stats["online"]      = new WebStatsEntry(0, false);
            Stats["online_max"]  = new WebStatsEntry(0, false);
            Stats["online_peak"] = new WebStatsEntry(0, true);

            Stats["unique"]      = new WebStatsEntry(0, false);
            Stats["unique_max"]  = new WebStatsEntry(0, false);
            Stats["unique_peak"] = new WebStatsEntry(0, true);

            Stats["items"]      = new WebStatsEntry(0, false);
            Stats["items_max"]  = new WebStatsEntry(0, false);
            Stats["items_peak"] = new WebStatsEntry(0, true);

            Stats["mobiles"]      = new WebStatsEntry(0, false);
            Stats["mobiles_max"]  = new WebStatsEntry(0, false);
            Stats["mobiles_peak"] = new WebStatsEntry(0, true);

            Stats["guilds"]      = new WebStatsEntry(0, false);
            Stats["guilds_max"]  = new WebStatsEntry(0, false);
            Stats["guilds_peak"] = new WebStatsEntry(0, true);

            Stats["memory"]      = new WebStatsEntry(0L, false);
            Stats["memory_max"]  = new WebStatsEntry(0L, false);
            Stats["memory_peak"] = new WebStatsEntry(0L, true);
        }
Esempio n. 2
0
        private static bool DeserializeStats(GenericReader reader)
        {
            var version = reader.GetVersion();

            switch (version)
            {
            case 0:
            {
                reader.ReadBlockDictionary(
                    r =>
                    {
                        var k = r.ReadString();
                        var v = new WebStatsEntry(r);

                        return(new KeyValuePair <string, WebStatsEntry>(k, v));
                    },
                    Stats);
            }
            break;
            }

            return(true);
        }