Exemplo n.º 1
0
        protected void ConnectionOnStateChanged(StateChange stateChange)
        {
            Log.InfoFormat("State Changed: {0}->{1}", stateChange.OldState, stateChange.NewState);
            switch (stateChange.NewState)
            {
            case ConnectionState.Connecting:
                break;

            case ConnectionState.Connected:
                // Created a task because if reconnecting, it seems that this message doesn't go through if it doesn't have a delay
                var t = new Task(() =>
                {
                    Thread.Sleep(1000);
                    if (GameStateEngine.GetContext().State.Status == EnumHostedGameStatus.Booting)
                    {
                        GameStateEngine.GetContext().SetStatus(EnumHostedGameStatus.Booted);
                    }
                    else
                    {
                        GameStateEngine.GetContext().SetStatus(GameStateEngine.GetContext().Game.Status);
                    }
                });
                t.Start();
                break;

            case ConnectionState.Reconnecting:
                break;

            case ConnectionState.Disconnected:
                break;
            }
            ConnectionState = stateChange.NewState;
        }
Exemplo n.º 2
0
 public new void Stop()
 {
     Log.Info("Stopping");
     Stopped = true;
     try
     {
         GameStateEngine.GetContext().SetStatus(EnumHostedGameStatus.GameShuttingDown);
     }
     catch (Exception e)
     {
         Log.Info(e.Message);
     }
     base.Stop();
     Log.Info("Stopped");
 }