コード例 #1
0
ファイル: ClientConnector.cs プロジェクト: jmenzel/AI-P
        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();
        }
コード例 #2
0
ファイル: ProxyService.cs プロジェクト: jmenzel/AI-P
 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);
 }
コード例 #3
0
ファイル: ProxyService.cs プロジェクト: jmenzel/AI-P
        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);
        }
コード例 #4
0
ファイル: ProxyToServer.cs プロジェクト: jmenzel/AI-P
 public void sendServerInfo(ServerInfo info)
 {
     registerServer(info);
 }