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 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); } } }