Exemple #1
0
        public ClientConnector(string server_name, int port)
        {
            this.HESName = server_name;
            this.HESPort = port;

            cpuCounter = new PerformanceCounter();

            cpuCounter.CategoryName = "Processor";
            cpuCounter.CounterName = "% Processor Time";
            cpuCounter.InstanceName = "_Total";

            ramCounter = new PerformanceCounter("Memory", "Available MBytes");

            getCurrentCpuUsage();
            getAvailableRAM();

            info = new ServerInfo(Guid.NewGuid(), this.HESName, System.Net.Dns.GetHostName(), this.HESPort.ToString(), "Service", ((uint)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds), getCurrentCpuUsage(), getAvailableRAM());

            RegisterProxyChannel();
            RegisterClientChannel();

            sendUpdate = true;
            updateThread = new Thread(new ThreadStart(sendingServerStatus));
            updateThread.Start();
        }
Exemple #2
0
 private void newClient(ClientInfo cInfo, ServerInfo sInfo)
 {
     //Aktuelle Nachricht speichern
     registeredClients[cInfo.id] = cInfo;
     registeredServer[sInfo.id].handeledClients.Add(cInfo.id);
     Console.WriteLine("Client " + cInfo.id + " -> " + cInfo.ip + ", " + cInfo.name + ", " + cInfo.applicationUptimeTimestamp);
 }
Exemple #3
0
        private void newServer(ServerInfo info)
        {
            if (!registeredServer.ContainsKey(info.id))
            {
                //Check if "new Server" in list with old GUID
                var oldS = registeredServer.Where(x => { return (x.Value.infoList.Last().ip == info.ip)
                                                               && (x.Value.infoList.Last().servicePort == info.servicePort)
                                                               && (x.Value.infoList.Last().name == info.name)
                                                               && (x.Value.infoList.Last().serviceName == info.serviceName);});

                foreach (KeyValuePair<Guid, ServerSession> pair in oldS.ToArray())
                {
                    registeredServer.Remove(pair.Key);
                }

                registeredServer[info.id] = new ServerSession { id = info.id, status = ServerStatus.Online };
            }
            if (registeredServer[info.id].infoList.Count > SERVER_SESSION_INFO_CAPACITY) registeredServer[info.id].infoList.RemoveAt(0);
            if (registeredServer[info.id].status == ServerStatus.NotAvailable) registeredServer[info.id].status = ServerStatus.Online;
            registeredServer[info.id].infoList.Add(info);
            registeredServer[info.id].lastReceivedTimestamp = (uint)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;

            Console.WriteLine("Server " + info.id + " -> " + info.name + ", " + info.ip + ", " + info.servicePort + ", " + info.serviceName + ", " + info.cpuUsagePercent + ", " + info.memoryUsagePercent);
        }
Exemple #4
0
 public void sendServerInfo(ServerInfo info)
 {
     registerServer(info);
 }