// copy constructor public UserGame(UserGame sourceGame) { Name = sourceGame.Name; Height = sourceGame.Height; Width = sourceGame.Width; Cells = sourceGame.Cells; }
public void StopGame() { lock (_golStateLock) { if (GolState == GolState.Running) { if (_timer != null) { _timer.Dispose(); } GolState = GolState.Stopped; // convert the Game to JSON //string currentGame = JsonConvert.SerializeObject(Game); // send the Game to the client UserGame currentGame = Game; var jsonGame = JsonConvert.SerializeObject(currentGame, new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.All }); Clients.All.updateGame(jsonGame); Clients.All.UpdateStoppedSessionGame(jsonGame); //BroadcastGolStateChange(GolState.Stopped); } } }
public void AddGame(UserGame game) { game.UserGameSessionID = sessionID; ActiveGames.Add(game); // TODO: // not sure if incrementing the sessionID here is corrcet sessionID++; }
public void StartGame(UserGame game) { lock (_golStateLock) { if (GolState != GolState.Running) { Game = game; //ConvertCells(game.Cells); _timer = new Timer(UpdateGolCells, null, _updateInterval, _updateInterval); GolState = GolState.Running; //BroadcastGolStateChange(GolState.Running); } } }
public void removeGame(UserGame game) { ActiveGames.Remove(game); }