예제 #1
0
 // copy constructor
 public UserGame(UserGame sourceGame)
 {
     Name   = sourceGame.Name;
     Height = sourceGame.Height;
     Width  = sourceGame.Width;
     Cells  = sourceGame.Cells;
 }
예제 #2
0
        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);
                }
            }
        }
예제 #3
0
 public void AddGame(UserGame game)
 {
     game.UserGameSessionID = sessionID;
     ActiveGames.Add(game);
     // TODO:
     // not sure if incrementing the sessionID here is corrcet
     sessionID++;
 }
예제 #4
0
        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);
                }
            }
        }
예제 #5
0
 public void removeGame(UserGame game)
 {
     ActiveGames.Remove(game);
 }