Exemplo n.º 1
0
        public static bool RegisterServer(int serverId, string ip, string host, int port)
        {
            RoomServer roomServer = CacheSet.RoomServerCache.FindKey(serverId);

            if (roomServer != null)
            {
//                 if (roomServer.State == (int)RoomServerState.Normal)
//                 {
//                     return false;
//                 }

                CacheSet.RoomServerCache.RemoveCache(roomServer);
                RoomServerSender.RemoveServer(serverId);
            }

            roomServer                 = new RoomServer();
            roomServer.Id              = serverId;
            roomServer.IP              = ip;
            roomServer.Port            = port;
            roomServer.Host            = host;
            roomServer.LastUpdatedTime = DateTime.UtcNow.Ticks;
            CacheSet.RoomServerCache.Add(roomServer);

            RoomServerSender.AddServer(serverId, ip, port);

            return(true);
        }
Exemplo n.º 2
0
        public static void UpdateServerState(string name, int roomCount, float cpuLoad, float memoryLoad)
        {
            RoomServer roomServer = CacheSet.RoomServerCache.FindKey(name);

            if (roomServer == null)
            {
                TraceLog.ReleaseWriteFatal(string.Format("Can not find server '{0}'.", name));
                return;
            }

            roomServer.ModifyLocked(() =>
            {
                roomServer.State           = RoomServerState.Normal;
                roomServer.LastUpdatedTime = DateTime.UtcNow.Ticks;
                roomServer.RoomCount       = roomCount;
                roomServer.CpuLoad         = cpuLoad;
                roomServer.MemoryLoad      = memoryLoad;
            });
        }