示例#1
0
        public static bool RegisterServer(int serverId, string ip, int port)
        {
            LobbyServer lobbyServer = CacheSet.LobbyServerCache.FindKey(serverId);

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

                CacheSet.LobbyServerCache.RemoveCache(lobbyServer);
                LobbyServerSender.RemoveServer(serverId);
            }

            lobbyServer                 = new LobbyServer();
            lobbyServer.Id              = serverId;
            lobbyServer.IP              = ip;
            lobbyServer.Port            = port;
            lobbyServer.LastUpdatedTime = DateTime.UtcNow.Ticks;
            CacheSet.LobbyServerCache.Add(lobbyServer);

            LobbyServerSender.AddServer(serverId, ip, port);

            return(true);
        }
示例#2
0
        public static void UpdateServerState(string name, float cpuLoad, float memoryLoad)
        {
            LobbyServer lobbyServer = CacheSet.LobbyServerCache.FindKey(name);

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

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