Beispiel #1
0
 public void Disconnected()
 {
     AppState    = UnityAppState.DISCONNECTED;
     AppTimeSpan = DateTime.Now.Subtract(AppStart);
     SendAppState();
     StateUpdater.Dispose();
     Log.Info("Simulation App has disconnected.");
 }
Beispiel #2
0
 public void Connected()
 {
     AppStart = DateTime.Now;
     SendAppState(UnityAppState.CONNECTED);
     AppState = UnityAppState.RUNNING;
     Log.Success("Simulation App is now connected!");
     statisticsService.InitializeStatisticsService();
     StateUpdater = new ActionTimer(() => SendAppState(), new TimeSpan(0, 0, 5));
 }
Beispiel #3
0
 public UnityAppManager(ILog Log, IHubContext <UIHub> hub, IStatisticsService statisticsService)
 {
     this.Log = Log;
     this.hub = hub;
     this.statisticsService = statisticsService;
     AppTimeSpan            = new TimeSpan();
     AppState = UnityAppState.NOT_CONNECTED;
     Log.Success("Unity App Communication Manager is now running.");
 }
 public async Task SignalForUnityAppConnectionStatus(UnityAppState state)
 {
     try
     {
         await Clients.All.SendAsync(SignalMethods.SignalForUnityAppConnectionStatus.Method, state);
     }
     catch (Exception ex)
     {
         Log.Error($"Exception was thrown while sending Unity App connection status {ex.Message}");
         throw new SignalHubException($"Error in SignalForUnityAppConnectionStatus method", ex);
     }
 }
Beispiel #5
0
        public void UpdateState(UnityAppState status)
        {
            switch (status)
            {
            case UnityAppState.CONNECTED:
                this.Connected();
                break;

            case UnityAppState.DISCONNECTED:
                this.Disconnected();
                break;
            }
        }
Beispiel #6
0
 public void SendAppState(UnityAppState state)
 {
     this.hub.Clients.All.SendAsync(SignalMethods.SignalForUnityAppConnectionStatus.Method, state);
 }
    public async Task Stop()
    {
        await ApiClient.GetAsync(Endpoints.Disconnect);

        this.AppState = UnityAppState.DISCONNECTED;
    }
    public async Task Start()
    {
        await ApiClient.GetAsync(Endpoints.Connect);

        this.AppState = UnityAppState.CONNECTED;
    }