Exemple #1
0
        //Fetching the norkonServerInfo .net object by deserializing Json text by fetching from URL
        private static async Task <NorkonServerInfo> GetServerStats(string cookie, CancellationToken cancellationToken = default)
        {
            if (cancellationToken.IsCancellationRequested)
            {
                client.CancelPendingRequests();
            }
            client.DefaultRequestHeaders.Remove("Cookie");
            client.DefaultRequestHeaders.Add("Cookie", cookie);
            var response = await client.GetAsync("https://investor.dn.no/JsonServer/GetStats");

            response.EnsureSuccessStatusCode();
            var content = await response.Content.ReadAsStringAsync();

            norkonServerInfo = JsonConvert.DeserializeObject <NorkonServerInfo>(content);
            return(norkonServerInfo);
        }
Exemple #2
0
        //Timer call back call at the interval of 1 second
        private static async void TimerCallback(Object o)
        {
            Console.WriteLine("Refreshing...");

            if (Counter == 0)
            {
                LoadCumulativeServerstats();
            }
            else
            {
                norkonServerInfo = await GetServerStats(cookies[Counter - 1]);

                DisplayServerStats(norkonServerInfo);
            }
            GC.Collect();
        }
Exemple #3
0
        private static async void LoadNextOrPreviousServerStats(CancellationToken cancellationToken = default)
        {
            if (Counter == 0)
            {
                Console.Clear();
                LoadCumulativeServerstats(cancellationToken);
            }
            else
            {
                norkonServerInfo = await GetServerStats(cookies[Counter - 1], cancellationToken);

                Console.Clear();
                DisplayServerStats(norkonServerInfo);
            }
            var keyStroke = Console.ReadKey(false);

            HandleToggleKeys(keyStroke.Key);
        }
Exemple #4
0
        //Displaying the Server info on the console
        private static void DisplayServerStats(NorkonServerInfo serverInfo)
        {
            Console.Clear();
            if (serverInfo.ServerName.ToUpper() == "ALL")
            {
                Console.ForegroundColor = ConsoleColor.Black;
                Console.BackgroundColor = ConsoleColor.White;
                Console.Write(serverInfo.ServerName + " ");
                Console.ResetColor();
            }
            else
            {
                Console.Write("ALL ");
            }
            foreach (string cookieKey in cookiekeys)
            {
                if (cookieKey.Substring(6, 4).ToUpper() == serverInfo.ServerName.ToUpper())
                {
                    Console.ForegroundColor = ConsoleColor.Black;
                    Console.BackgroundColor = ConsoleColor.White;
                    Console.Write(cookieKey.Substring(6, 4) + " ", ConsoleColor.Green);
                    Console.ResetColor();
                }
                else
                {
                    Console.Write(cookieKey.Substring(6, 4) + " ");
                }
            }

            Console.WriteLine("");
            Console.WriteLine("Server Name: " + serverInfo.ServerName);
            Console.WriteLine("Connection Count: " + serverInfo.QuantHubs.Connected.ToString());
            TimeSpan timespan = TimeSpan.FromSeconds(serverInfo.Process.Uptime);
            string   Uptime   = string.Format("{0:D2}:{1:D2}:{2:D2}:{2:D2}",
                                              timespan.Hours, timespan.Minutes, timespan.Seconds, timespan.Milliseconds);

            Console.WriteLine("Uptime: " + Uptime);
            Console.WriteLine("Fragment Updates : " + serverInfo.Updates.Frag.ToString());
            Console.WriteLine("Http Request Count : " + serverInfo.HttpRecCount.Http.ToString());
            Console.WriteLine("Fallback ready  : " + serverInfo.FallbackMgr.FallbackReady.ToString());

            Console.WriteLine("");
            Console.WriteLine("use only <- or -> to toggle between servers or ESC to exit ");
        }