public static bool Init(GameServerConfig config) { RateMgr.m_lock.AcquireWriterLock(-1); bool result; try { using (ServiceBussiness db = new ServiceBussiness()) { RateMgr.m_RateInfos = db.GetRate(config.ServerID); } result = true; } catch (Exception e) { RateMgr.log.Error("RateMgr", e); result = false; } finally { RateMgr.m_lock.ReleaseWriterLock(); } return(result); }
public static NetState GameServerClient(GameServerConfig config) { if (config == null) { return(null); } String address = config.Address.ToString(); NetState ns = (NetState)m_GameServers[address]; if (ns != null) { return(ns); } try { ns = new NetState(config.Address, Core.MessagePump); ns.Start(); ns.Send(new SendSeed()); m_GameServers[address] = ns; return(ns); } catch (Exception e) { Console.WriteLine("Exception while trying to connect to game server {0} ({1}): {2}", config.Name, address, e); return(null); } }
public static bool Init(GameServerConfig config) { RateMgr.m_lock.AcquireWriterLock(15000); bool result; try { using (ServiceBussiness serviceBussiness = new ServiceBussiness()) { RateMgr.m_RateInfos = serviceBussiness.GetRate(config.ServerID); } result = true; } catch (Exception exception) { if (RateMgr.log.IsErrorEnabled) { RateMgr.log.Error("RateMgr", exception); } result = false; } finally { RateMgr.m_lock.ReleaseWriterLock(); } return(result); }
public static void PlayServer(NetState state, PacketReader pvSrc) { int index = pvSrc.ReadInt16(); ServerInfo[] info = state.ServerInfo; IAccount a = state.Account; if (info == null || a == null || index < 0 || index >= info.Length) { state.Dispose(); } else { ServerInfo si = info[index]; PlayServerAck.m_AuthID = GenerateAuthID(); /* send AuthID to game server? */ GameServerConfig config = Core.Config.GameServerListConfig[si.Name]; if (config != null && config.SendAuthID) { NetState ns2 = NetState.GameServerClient(config); if (ns2 != null) { ns2.Send(new AddAuthID(PlayServerAck.m_AuthID, state.Account.ToString())); } } state.SentFirstPacket = false; state.Send(new PlayServerAck(si)); Console.WriteLine("Client {0} playing server '{1}'", state, si.Name); } }
/// <summary>Snippet for CreateGameServerConfig</summary> public void CreateGameServerConfigRequestObject() { // Snippet: CreateGameServerConfig(CreateGameServerConfigRequest, CallSettings) // Create client GameServerConfigsServiceClient gameServerConfigsServiceClient = GameServerConfigsServiceClient.Create(); // Initialize request argument(s) CreateGameServerConfigRequest request = new CreateGameServerConfigRequest { ParentAsGameServerDeploymentName = GameServerDeploymentName.FromProjectLocationDeployment("[PROJECT]", "[LOCATION]", "[DEPLOYMENT]"), ConfigId = "", GameServerConfig = new GameServerConfig(), }; // Make the request Operation <GameServerConfig, OperationMetadata> response = gameServerConfigsServiceClient.CreateGameServerConfig(request); // Poll until the returned long-running operation is complete Operation <GameServerConfig, OperationMetadata> completedResponse = response.PollUntilCompleted(); // Retrieve the operation result GameServerConfig result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <GameServerConfig, OperationMetadata> retrievedResponse = gameServerConfigsServiceClient.PollOnceCreateGameServerConfig(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result GameServerConfig retrievedResult = retrievedResponse.Result; } // End snippet }
/// <summary>Snippet for CreateGameServerConfigAsync</summary> public async Task CreateGameServerConfigAsync() { // Snippet: CreateGameServerConfigAsync(string, GameServerConfig, CallSettings) // Additional: CreateGameServerConfigAsync(string, GameServerConfig, CancellationToken) // Create client GameServerConfigsServiceClient gameServerConfigsServiceClient = await GameServerConfigsServiceClient.CreateAsync(); // Initialize request argument(s) string parent = "projects/[PROJECT]/locations/[LOCATION]/gameServerDeployments/[DEPLOYMENT]"; GameServerConfig gameServerConfig = new GameServerConfig(); // Make the request Operation <GameServerConfig, OperationMetadata> response = await gameServerConfigsServiceClient.CreateGameServerConfigAsync(parent, gameServerConfig); // Poll until the returned long-running operation is complete Operation <GameServerConfig, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result GameServerConfig result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <GameServerConfig, OperationMetadata> retrievedResponse = await gameServerConfigsServiceClient.PollOnceCreateGameServerConfigAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result GameServerConfig retrievedResult = retrievedResponse.Result; } // End snippet }
public static GameServer Create(GameServerConfig config) { var instance = new GameServer(); // TODO(sorae): impl.. return(instance); }
public static GameServerConfig Create(string[] args) { var instance = new GameServerConfig(); // TODO(sorae): impl.. return(instance); }
/// <summary>Snippet for GetGameServerConfig</summary> public void GetGameServerConfig() { // Snippet: GetGameServerConfig(string, CallSettings) // Create client GameServerConfigsServiceClient gameServerConfigsServiceClient = GameServerConfigsServiceClient.Create(); // Initialize request argument(s) string name = "projects/[PROJECT]/locations/[LOCATION]/gameServerDeployments/[DEPLOYMENT]/configs/[CONFIG]"; // Make the request GameServerConfig response = gameServerConfigsServiceClient.GetGameServerConfig(name); // End snippet }
/// <summary>Snippet for GetGameServerConfig</summary> public void GetGameServerConfigResourceNames() { // Snippet: GetGameServerConfig(GameServerConfigName, CallSettings) // Create client GameServerConfigsServiceClient gameServerConfigsServiceClient = GameServerConfigsServiceClient.Create(); // Initialize request argument(s) GameServerConfigName name = GameServerConfigName.FromProjectLocationDeploymentConfig("[PROJECT]", "[LOCATION]", "[DEPLOYMENT]", "[CONFIG]"); // Make the request GameServerConfig response = gameServerConfigsServiceClient.GetGameServerConfig(name); // End snippet }
private static bool StartServer() { FileInfo fileInfo = new FileInfo(Assembly.GetExecutingAssembly().Location); Directory.SetCurrentDirectory(fileInfo.DirectoryName); new FileInfo("./config/serverconfig.xml"); GameServerConfig config = new GameServerConfig(); GameServer.CreateInstance(config); return(GameServer.Instance.Start()); }
public ServerQuery(GameServerConfig config) { m_Config = config; try { m_Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); /* connect socket */ m_Callback = new AsyncCallback(OnConnect); m_Socket.BeginConnect(m_Config.Address, m_Callback, null); } catch (Exception ex) { Console.WriteLine(ex); } }
/// <summary>Snippet for GetGameServerConfigAsync</summary> public async Task GetGameServerConfigAsync() { // Snippet: GetGameServerConfigAsync(string, CallSettings) // Additional: GetGameServerConfigAsync(string, CancellationToken) // Create client GameServerConfigsServiceClient gameServerConfigsServiceClient = await GameServerConfigsServiceClient.CreateAsync(); // Initialize request argument(s) string name = "projects/[PROJECT]/locations/[LOCATION]/gameServerDeployments/[DEPLOYMENT]/configs/[CONFIG]"; // Make the request GameServerConfig response = await gameServerConfigsServiceClient.GetGameServerConfigAsync(name); // End snippet }
/// <summary>Snippet for GetGameServerConfigAsync</summary> public async Task GetGameServerConfigResourceNamesAsync() { // Snippet: GetGameServerConfigAsync(GameServerConfigName, CallSettings) // Additional: GetGameServerConfigAsync(GameServerConfigName, CancellationToken) // Create client GameServerConfigsServiceClient gameServerConfigsServiceClient = await GameServerConfigsServiceClient.CreateAsync(); // Initialize request argument(s) GameServerConfigName name = GameServerConfigName.FromProjectLocationDeploymentConfig("[PROJECT]", "[LOCATION]", "[DEPLOYMENT]", "[CONFIG]"); // Make the request GameServerConfig response = await gameServerConfigsServiceClient.GetGameServerConfigAsync(name); // End snippet }
public GameServer(GameServerConfig config) { if (config is null) { throw new ArgumentNullException(nameof(config)); } address = config.Address ?? IPAddress.Any; port = config.Port == 0 ? (ushort)25565 : config.Port; acceptQueueLength = config.AcceptQueueLength == 0 ? 10 : config.AcceptQueueLength; listenDelay = config.ListenDelay == 0 ? 100 : config.ListenDelay; handler = config.Handler ?? throw new ArgumentNullException(nameof(config)); pool = new List <GameUser>(16); }
public GameServerConfig GetConfig( string projectId, string regionId, string deploymentId, string configId) { // Create the client. GameServerConfigsServiceClient client = GameServerConfigsServiceClient.Create(); GetGameServerConfigRequest request = new GetGameServerConfigRequest { GameServerConfigName = GameServerConfigName.FromProjectLocationDeploymentConfig(projectId, regionId, deploymentId, configId) }; // Make the request. GameServerConfig response = client.GetGameServerConfig(request); return(response); }
public static bool Init(GameServerConfig config) { m_lock.AcquireWriterLock(Timeout.Infinite); try { using (ServiceBussiness db = new ServiceBussiness()) { m_RateInfos = db.GetRate(config.ServerID); } return true; } catch (Exception e) { if (log.IsErrorEnabled) log.Error("RateMgr", e); return false; } finally { m_lock.ReleaseWriterLock(); } }
public static bool Setup(GameServerConfig config) { BattleMgr.m_list.Clear(); if (File.Exists("battle.xml")) { try { BattleMgr.AddBattleServer(new BattleServer(1, config.FightIP, config.FightPort, config.FightKey, true, false)); if (config.IsOpenCrossFight) { BattleMgr.AddBattleServer(new BattleServer(2, config.CrossFightIP, config.CrossFightPort, config.CrossFightKey, true, true)); IsOpenAreaFight = true; } } catch (Exception ex) { BattleMgr.log.Error("BattleMgr setup error:", ex); } } BattleMgr.log.InfoFormat("BattlMgr:total {0} battle server loaded.", BattleMgr.m_list.Count); return(true); }
public async stt::Task GetGameServerConfigRequestObjectAsync() { moq::Mock <GameServerConfigsService.GameServerConfigsServiceClient> mockGrpcClient = new moq::Mock <GameServerConfigsService.GameServerConfigsServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetGameServerConfigRequest request = new GetGameServerConfigRequest { GameServerConfigName = GameServerConfigName.FromProjectLocationDeploymentConfig("[PROJECT]", "[LOCATION]", "[DEPLOYMENT]", "[CONFIG]"), }; GameServerConfig expectedResponse = new GameServerConfig { GameServerConfigName = GameServerConfigName.FromProjectLocationDeploymentConfig("[PROJECT]", "[LOCATION]", "[DEPLOYMENT]", "[CONFIG]"), CreateTime = new wkt::Timestamp(), UpdateTime = new wkt::Timestamp(), Labels = { { "key8a0b6e3c", "value60c16320" }, }, FleetConfigs = { new FleetConfig(), }, ScalingConfigs = { new ScalingConfig(), }, Description = "description2cf9da67", }; mockGrpcClient.Setup(x => x.GetGameServerConfigAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <GameServerConfig>(stt::Task.FromResult(expectedResponse), null, null, null, null)); GameServerConfigsServiceClient client = new GameServerConfigsServiceClientImpl(mockGrpcClient.Object, null); GameServerConfig responseCallSettings = await client.GetGameServerConfigAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); GameServerConfig responseCancellationToken = await client.GetGameServerConfigAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
private static bool StartServer() { //TODO parse args for -config parameter! FileInfo dolserver = new FileInfo(Assembly.GetExecutingAssembly().Location); Directory.SetCurrentDirectory(dolserver.DirectoryName); FileInfo configFile = new FileInfo("./config/serverconfig.xml"); GameServerConfig config = new GameServerConfig(); //if (configFile.Exists) //{ // config.LoadFromXMLFile(configFile); //} //else //{ // if (!configFile.Directory.Exists) // configFile.Directory.Create(); // config.SaveToXMLFile(configFile); //} GameServer.CreateInstance(config); return(GameServer.Instance.Start()); }
public static bool Init(GameServerConfig config) { m_lock.AcquireWriterLock(Timeout.Infinite); try { using (ServiceBussiness db = new ServiceBussiness()) { m_RateInfos = db.GetRate(config.ServerID); } return(true); } catch (Exception e) { if (log.IsErrorEnabled) { log.Error("RateMgr", e); } return(false); } finally { m_lock.ReleaseWriterLock(); } }
public void GetGameServerConfigRequestObject() { moq::Mock <GameServerConfigsService.GameServerConfigsServiceClient> mockGrpcClient = new moq::Mock <GameServerConfigsService.GameServerConfigsServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetGameServerConfigRequest request = new GetGameServerConfigRequest { GameServerConfigName = GameServerConfigName.FromProjectLocationDeploymentConfig("[PROJECT]", "[LOCATION]", "[DEPLOYMENT]", "[CONFIG]"), }; GameServerConfig expectedResponse = new GameServerConfig { GameServerConfigName = GameServerConfigName.FromProjectLocationDeploymentConfig("[PROJECT]", "[LOCATION]", "[DEPLOYMENT]", "[CONFIG]"), CreateTime = new wkt::Timestamp(), UpdateTime = new wkt::Timestamp(), Labels = { { "key8a0b6e3c", "value60c16320" }, }, FleetConfigs = { new FleetConfig(), }, ScalingConfigs = { new ScalingConfig(), }, Description = "description2cf9da67", }; mockGrpcClient.Setup(x => x.GetGameServerConfig(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); GameServerConfigsServiceClient client = new GameServerConfigsServiceClientImpl(mockGrpcClient.Object, null); GameServerConfig response = client.GetGameServerConfig(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
private static void Main(string[] args) { var parsedArgs = ArgsOptions.Parse(args); parsedArgs.GameInfoJson = LoadConfig( parsedArgs.GameInfoJsonPath, parsedArgs.GameInfoJson, Encoding.UTF8.GetString(Resources.GameInfo)); var gameServerBlowFish = "17BLOhi6KZsTtldTsizvHg=="; var gameServerLauncher = new GameServerLauncher( parsedArgs.ServerPort, parsedArgs.GameInfoJson, gameServerBlowFish); #if DEBUG var configGameServerSettings = GameServerConfig.LoadFromJson(LoadConfig( parsedArgs.GameServerSettingsJsonPath, parsedArgs.GameServerSettingsJson, Encoding.UTF8.GetString(Resources.GameServerSettings))); if (configGameServerSettings.AutoStartClient) { var leaguePath = configGameServerSettings.ClientLocation; if (Directory.Exists(leaguePath)) { leaguePath = Path.Combine(leaguePath, "League of Legends.exe"); } if (File.Exists(leaguePath)) { var startInfo = new ProcessStartInfo(leaguePath) { Arguments = String.Format("\"8394\" \"LoLLauncher.exe\" \"\" \"127.0.0.1 {0} {1} 1\"", parsedArgs.ServerPort, gameServerBlowFish), WorkingDirectory = Path.GetDirectoryName(leaguePath) }; var leagueProcess = Process.Start(startInfo); _logger.Info("Launching League of Legends. You can disable this in GameServerSettings.json."); if (Environment.OSVersion.Platform == PlatformID.Win32NT || Environment.OSVersion.Platform == PlatformID.Win32S || Environment.OSVersion.Platform == PlatformID.Win32Windows || Environment.OSVersion.Platform == PlatformID.WinCE) { WindowsConsoleCloseDetection.SetCloseHandler((_) => { if (!leagueProcess.HasExited) { leagueProcess.Kill(); } return(true); }); } } else { _logger.Warn("Unable to find League of Legends.exe. Check the GameServerSettings.json settings and your League location."); } } else { _logger.Info("Server is ready, clients can now connect."); } #endif gameServerLauncher.StartNetworkLoop(); Console.ReadLine(); }
public static ServerStatus GetStatus(GameServerConfig config) { return m_Status == null ? null : (ServerStatus)m_Status[config]; }
public static void SetStatus(GameServerConfig config, ServerStatus status) { m_Status[config] = status; }
public static void CreateConfig() { Configuration = new GameServerConfig(); Configuration.Refresh(); }
public static ServerStatus GetStatus(GameServerConfig config) { return(m_Status == null ? null : (ServerStatus)m_Status[config]); }
public AppConfigManager() { GameServerConfig = new GameServerConfig(); }
public async Task <GameServerConfig> CreateConfigAsync( string projectId, string regionId, string deploymentId, string configId) { // Create the client. GameServerConfigsServiceClient client = await GameServerConfigsServiceClient.CreateAsync(); GameServerConfig config = new GameServerConfig { GameServerConfigName = GameServerConfigName.FromProjectLocationDeploymentConfig(projectId, regionId, deploymentId, configId), Description = "My Game Server Config", FleetConfigs = { new FleetConfig { Name = "fleet-spec-1", FleetSpec = JsonConvert.SerializeObject(new { replicas = 10, scheduling = "Packed", strategy = new { type = "RollingUpdate", rollingUpdate = new { maxSurge = "25%", maxUnavailable = "25%", } }, template = new { metadata = new { labels = new { gameName = "udp-server", } }, spec = new { ports = new [] { new { name = "default", portPolicy = "Dynamic", containerPort = 7654, protocol = "UDP", } }, health = new { initialDelaySeconds = 30, periodSeconds = 60, }, sdkServer = new { logLevel = "Info", grpcPort = 9357, httpPort = 9358, }, template = new { spec = new { containers = new []{ new { name = "dedicated", image = "gcr.io/agones-images/udp-server:0.21", imagePullPolicy = "Always", resources = new { requests = new { memory = "200Mi", cpu = "500m", }, limits = new { memory = "200Mi", cpu = "500m", } } } } } } } } }) } } }; CreateGameServerConfigRequest request = new CreateGameServerConfigRequest { ParentAsGameServerDeploymentName = GameServerDeploymentName.FromProjectLocationDeployment(projectId, regionId, deploymentId), ConfigId = configId, GameServerConfig = config }; // Make the request. Operation <GameServerConfig, OperationMetadata> response = await client.CreateGameServerConfigAsync(request); // Poll until the returned long-running operation is complete. Operation <GameServerConfig, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result. return(completedResponse.Result); }