private void Start() { var mainMenuViewModel = new MainMenuViewModel(); var inGameViewModel = new InGameViewModel(); var loadingViewModel = new LoadingViewModel(); InstantiateViews(mainMenuViewModel, inGameViewModel, loadingViewModel); // TODO: these services should be unique, instantiate it in a previous step var gameRepository = new GameRepository(); var gameServerService = new GameServerService ( new RestRestClientAdapter(new JsonUtilityAdapter()), gameRepository ); var eventDispatcherService = new EventDispatcherService(); var startGameUseCase = new StartGameUseCase(gameServerService, gameRepository, new ConfigurationGameRepository(), eventDispatcherService); var startGameController = new StartGameController(mainMenuViewModel, startGameUseCase ); var keyboardController = new KeyboardController(inGameViewModel, new GuessLetterUseCase( new CheckSolutionUseCase( gameServerService, gameRepository, eventDispatcherService ), gameRepository, gameServerService, eventDispatcherService ) ); var restartGameController = new RestartGameController(inGameViewModel, new RestartGameUseCase(startGameUseCase, eventDispatcherService)); var updateWordPresenter = new InGamePresenter(inGameViewModel, eventDispatcherService); var mainMenuPresenter = new MainMenuPresenter(mainMenuViewModel, eventDispatcherService); var loadingPresenter = new LoadingPresenter(loadingViewModel, eventDispatcherService); }
public void OnAction(Hashtable parameters) { ArrayList arrayList = new ArrayList(); arrayList.Add("/LogToConsole=false"); StringBuilder stringBuilder = new StringBuilder(); foreach (DictionaryEntry dictionaryEntry in parameters) { if (stringBuilder.Length > 0) { stringBuilder.Append(" "); } stringBuilder.Append(dictionaryEntry.Key); stringBuilder.Append("="); stringBuilder.Append(dictionaryEntry.Value); } arrayList.Add("commandline=" + stringBuilder.ToString()); string[] commandLine = (string[])arrayList.ToArray(typeof(string)); AssemblyInstaller assemblyInstaller = new AssemblyInstaller(Assembly.GetExecutingAssembly(), commandLine); Hashtable hashtable = new Hashtable(); if (GameServerService.GetDOLService() != null) { Console.WriteLine("DOL service is already installed!"); return; } Console.WriteLine("Installing Road as system service..."); try { assemblyInstaller.Install(hashtable); assemblyInstaller.Commit(hashtable); } catch (Exception ex) { assemblyInstaller.Rollback(hashtable); Console.WriteLine("Error installing as system service"); Console.WriteLine(ex.Message); return; } Console.WriteLine("Finished!"); }
public GameServer(int port = 50051) { _port = port; _gameServerService = new GameServerServiceImpl(); _matchMakerService = new MatchMakerService(_gameServerService); _server = new Server { Services = { GameServerService.BindService(_gameServerService) }, Ports = { new ServerPort("localhost", _port, ServerCredentials.Insecure) } }; }
/// <summary> /// Each time an application receives new request, this method checks wether or not its web socket /// request. If it is, then the request is being handled accordingly. /// </summary> public async Task InvokeAsync(HttpContext httpContext, [FromServices] GameServerService gameServer) { if (httpContext.Request.Path == "/ws") { if (httpContext.WebSockets.IsWebSocketRequest) { WebSocket webSocket = await httpContext.WebSockets.AcceptWebSocketAsync(); // Pass new web socket to be handled. await gameServer.HandleWebSocketAsync(webSocket); } else { httpContext.Response.StatusCode = 400; } } else { await _next(httpContext); } }
private static void Main(string[] args) { Logs.AddConsoleAppender(); GameServerService.StartTaskThread(); //test1(); //test2(); TestMove(); while (true) { if (Console.ReadKey(false).Key == ConsoleKey.Escape) { break; } Thread.Sleep(100); } GameServerService.RunType = ServerStateType.Closing; }
private async Task GetOrCreateModset(GameServerConfiguration gsc, Modset modset) { var existing = await _context.Modsets.FirstOrDefaultAsync(m => m.Name == modset.Name && m.ConfigurationFile == modset.ConfigurationFile); if (existing != null) { gsc.Modset = existing; gsc.ModsetID = existing.ModsetID; } else { modset.GameType = GameServerType.Arma3; modset.AccessToken = GameServerService.GenerateToken(); modset.Label = modset.Name; _context.Add(modset); await _context.SaveChangesAsync(); gsc.Modset = modset; gsc.ModsetID = modset.ModsetID; } }
public void OnAction(Hashtable parameters) { ServiceController svcc = GameServerService.GetDOLService(); if (svcc == null) { Console.WriteLine("You have to install the service first!"); return; } if (svcc.Status == ServiceControllerStatus.StartPending) { Console.WriteLine("Server is still starting, please check the logfile for progress information!"); return; } if (svcc.Status != ServiceControllerStatus.Stopped) { Console.WriteLine("The DOL service is not stopped"); return; } try { Console.WriteLine("Starting the DOL service..."); svcc.Start(); svcc.WaitForStatus(ServiceControllerStatus.StartPending, TimeSpan.FromSeconds(10)); Console.WriteLine("Starting can take some time, please check the logfile for progress information!"); Console.WriteLine("Finished!"); } catch (InvalidOperationException e) { Console.WriteLine("Could not start the DOL service!"); Console.WriteLine(e.Message); } catch (System.ServiceProcess.TimeoutException) { Console.WriteLine("Error starting the service, please check the logfile for further info!"); } }
private async Task <GameServerConfiguration> GetActiveConfiguration(GameServer gameServer) { var currentConfig = await _context.GameServerConfigurations .Include(g => g.Files) .Include(g => g.Modset) .Where(g => g.GameServerID == gameServer.GameServerID && g.IsActive) .FirstOrDefaultAsync(); if (currentConfig == null) { currentConfig = new GameServerConfiguration() { IsActive = true, GameServer = gameServer, Label = "Default", Files = new List <GameConfigurationFile>(), AccessToken = GameServerService.GenerateToken() }; _context.Add(currentConfig); await _context.SaveChangesAsync(); } return(currentConfig); }
public void OnAction(Hashtable parameters) { ServiceController svcc = GameServerService.GetDOLService(); if (svcc == null) { Console.WriteLine("You have to install the service first!"); return; } if (svcc.Status == ServiceControllerStatus.StartPending) { Console.WriteLine("Server is still starting, please check the logfile for progress information!"); return; } if (svcc.Status != ServiceControllerStatus.Running) { Console.WriteLine("The DOL service is not running"); return; } try { Console.WriteLine("Stopping the DOL service..."); svcc.Stop(); svcc.WaitForStatus(ServiceControllerStatus.Stopped); Console.WriteLine("Finished!"); } catch (InvalidOperationException e) { Console.WriteLine("Could not stop the DOL service!"); Console.WriteLine(e.Message); return; } }
public void Initializationing() { LoadAccountFromDB(); GameServerService.GetWorldInstatnce().NetStateDisconnect += OnNetStateDisconnect; GameServerService.GetWorldInstatnce().NetStateConnect += OnNetStateConnect; }
public AdminGameServersController(ILogger <AdminGameServersController> logger, GameServerService service, GameServerManagerContext context, IHttpClientFactory factory) { _logger = logger; _service = service; _context = context; _factory = factory; }
/// <summary> /// 注册一个控制台的GM指令 /// 方法同 GameServerService.RegisterConsoleCommand 一致 /// 只不过多放一个地方,方便调用而已 /// </summary> /// <param name="commandName"></param> /// <param name="fun"></param> public static void RegisterConsoleCommand(string commandName, GameServerService.CommandCallbackDelegate fun) { GameServerService.RegisterConsoleCommand(commandName, fun); }
public IActionResult Status([FromServices] GameServerService gameServer) { ViewData["Lobbies"] = gameServer.GetLobbyStatus(); return(View()); }
public AdminGameServerConfigurationsController(GameServerManagerContext context, GameServerService service) { _context = context; _service = service; }
/// <summary> /// Execute /// </summary> public override void Execute() { GameServerService.StartServer(ServerPort); }
public void Release() { GameServerService.GetWorldInstatnce().NetStateDisconnect -= OnNetStateDisconnect; }
private void FrmMain_FormClosing(object sender, FormClosingEventArgs e) { GameServerService.StopGame(); }
public AdminModsetsController(GameServerManagerContext context, GameServerService service) { _context = context; _service = service; }
public ServerController(GameServerService service) { _service = service; }