예제 #1
0
 public void UpdateServerAdvertisement(IGluonSession session, AdvertiseCapacity request)
 {
     lock (Servers)
     {
         var state = GetState(session);
         if (state == null)
         {
             state = new LotServerState {
                 Session = session
             };
             Servers.Add(state);
             if (ServersByCallsign.ContainsKey(session.CallSign))
             {
                 ServersByCallsign[session.CallSign] = state;
             }
             else
             {
                 ServersByCallsign.Add(session.CallSign, state);
             }
         }
         state.Session       = session; //can be hot-swapped if we re-establish connection. TODO: verify and look for race conditions
         state.MaxLots       = request.MaxLots;
         state.CurrentLots   = request.CurrentLots;
         state.CpuPercentAvg = request.CpuPercentAvg;
         state.RamAvaliable  = request.RamAvaliable;
         state.RamUsed       = request.RamUsed;
     }
 }
예제 #2
0
        private void CheckConnections()
        {
            while (_Running)
            {
                float cpu = 1;
                if (PerformanceCounterCategory.Exists("Processor"))
                {
                    cpu = CpuCounter.NextValue();
                }
                var capacity = new AdvertiseCapacity
                {
                    CpuPercentAvg = (byte)(cpu * 100),
                    CurrentLots   = LotCount,
                    MaxLots       = (short)Config.Max_Lots,
                    RamAvaliable  = 0,
                    RamUsed       = 0
                };

                //Repair & advertise connections
                foreach (var connection in Connections.Values)
                {
                    if (!connection.Connected)
                    {
                        LOG.Info("Not connected!");
                        connection.Connect();
                    }
                    else
                    {
                        connection.Write(capacity);
                    }
                }

                Thread.Sleep(Config.CityReportingInterval);
            }
        }
예제 #3
0
 public void Handle(IGluonSession session, AdvertiseCapacity capacity)
 {
     PickingEngine.UpdateServerAdvertisement(session, capacity);
 }