Пример #1
0
        public static GeneralStatistics GetGeneralStatistics(StatisticsQueryFlags queryFlags)
        {
            GeneralStatistics stat = new GeneralStatistics();

            stat.QueryFlags = queryFlags;

            if ((queryFlags & StatisticsQueryFlags.Connections) != 0)
            {
                int connections = 0;
                foreach (var conn in HTTPManager.Connections)
                {
                    if (conn.Value != null)
                    {
                        connections += conn.Value.Count;
                    }
                }

#if !BESTHTTP_DISABLE_WEBSOCKET && UNITY_WEBGL && !UNITY_EDITOR
                connections += WebSocket.WebSocket.WebSockets.Count;
#endif

                stat.Connections       = connections;
                stat.ActiveConnections = ActiveConnections.Count
#if !BESTHTTP_DISABLE_WEBSOCKET && UNITY_WEBGL && !UNITY_EDITOR
                                         + WebSocket.WebSocket.WebSockets.Count
#endif
                ;
                stat.FreeConnections     = FreeConnections.Count;
                stat.RecycledConnections = RecycledConnections.Count;
                stat.RequestsInQueue     = RequestQueue.Count;
            }

#if !BESTHTTP_DISABLE_CACHING && (!UNITY_WEBGL || UNITY_EDITOR)
            if ((queryFlags & StatisticsQueryFlags.Cache) != 0)
            {
                stat.CacheEntityCount = HTTPCacheService.GetCacheEntityCount();
                stat.CacheSize        = HTTPCacheService.GetCacheSize();
            }
#endif

#if !BESTHTTP_DISABLE_COOKIES && (!UNITY_WEBGL || UNITY_EDITOR)
            if ((queryFlags & StatisticsQueryFlags.Cookies) != 0)
            {
                List <Cookies.Cookie> cookies = Cookies.CookieJar.GetAll();
                stat.CookieCount = cookies.Count;
                uint cookiesSize = 0;
                for (int i = 0; i < cookies.Count; ++i)
                {
                    cookiesSize += cookies[i].GuessSize();
                }
                stat.CookieJarSize = cookiesSize;
            }
#endif

            return(stat);
        }
Пример #2
0
        public static GeneralStatistics GetGeneralStatistics(StatisticsQueryFlags queryFlags)
        {
            GeneralStatistics stat = new GeneralStatistics();

            stat.QueryFlags = queryFlags;

            if ((queryFlags & StatisticsQueryFlags.Connections) != 0)
            {
                int connections = 0;
                foreach (var conn in HTTPManager.Connections)
                {
                    if (conn.Value != null)
                    {
                        connections += conn.Value.Count;
                    }
                }

                stat.Connections         = connections;
                stat.ActiveConnections   = ActiveConnections.Count;
                stat.FreeConnections     = FreeConnections.Count;
                stat.RecycledConnections = RecycledConnections.Count;
                stat.RequestsInQueue     = RequestQueue.Count;
            }

            if ((queryFlags & StatisticsQueryFlags.Cache) != 0)
            {
                stat.CacheEntityCount = HTTPCacheService.GetCacheEntityCount();
                stat.CacheSize        = HTTPCacheService.GetCacheSize();
            }

            if ((queryFlags & StatisticsQueryFlags.Cookies) != 0)
            {
                List <Cookies.Cookie> cookies = Cookies.CookieJar.GetAll();
                stat.CookieCount = cookies.Count;
                uint cookiesSize = 0;
                for (int i = 0; i < cookies.Count; ++i)
                {
                    cookiesSize += cookies [i].GuessSize();
                }
                stat.CookieJarSize = cookiesSize;
            }

            return(stat);
        }
Пример #3
0
        public static GeneralStatistics GetGeneralStatistics(StatisticsQueryFlags queryFlags)
        {
            GeneralStatistics result = default(GeneralStatistics);

            result.QueryFlags = queryFlags;
            if ((byte)(queryFlags & StatisticsQueryFlags.Connections) != 0)
            {
                int num = 0;
                foreach (KeyValuePair <string, List <HTTPConnection> > current in HTTPManager.Connections)
                {
                    if (current.Value != null)
                    {
                        num += current.Value.Count;
                    }
                }
                result.Connections         = num;
                result.ActiveConnections   = HTTPManager.ActiveConnections.Count;
                result.FreeConnections     = HTTPManager.FreeConnections.Count;
                result.RecycledConnections = HTTPManager.RecycledConnections.Count;
                result.RequestsInQueue     = HTTPManager.RequestQueue.Count;
            }
            if ((byte)(queryFlags & StatisticsQueryFlags.Cache) != 0)
            {
                result.CacheEntityCount = HTTPCacheService.GetCacheEntityCount();
                result.CacheSize        = HTTPCacheService.GetCacheSize();
            }
            if ((byte)(queryFlags & StatisticsQueryFlags.Cookies) != 0)
            {
                List <Cookie> all = CookieJar.GetAll();
                result.CookieCount = all.Count;
                uint num2 = 0u;
                for (int i = 0; i < all.Count; i++)
                {
                    num2 += all[i].GuessSize();
                }
                result.CookieJarSize = num2;
            }
            return(result);
        }
    void OnGUI()
    {
        GUI.Label(new Rect(5, 5, Screen.width - 10, 30), string.Format("Cache size: {0,10:N0} Entity Count: {1}", HTTPCacheService.GetCacheSize(), HTTPCacheService.GetCacheEntityCount()));

        float height = (Screen.height - 300) / TestScenes.Length;

        if (GUI.Button(new Rect(5, 40, Screen.width, height), "Clear Cache"))
        {
            BestHTTP.Caching.HTTPCacheService.BeginClear();
        }

        for (int i = 0; i < TestScenes.Length; ++i)
        {
            if (GUI.Button(new Rect(3, 300 + (i * height), Screen.width - 6, height), TestScenes[i]))
            {
                Application.LoadLevel(TestScenes[i]);
            }
        }
    }