Exemplo n.º 1
0
 public DisconectedStateSpecs(ITestOutputHelper output) : base(output)
 {
     _context        = new FakeConnectionContext();
     _connectionInfo = new ConnectionInfo("", 0, "", "");
     _timer          = new FakeTimer();
     _state          = GetState();
 }
Exemplo n.º 2
0
        void ITransportListener.OnTransportEvent(TransportState transportState, Exception ex)
        {
            ExecuteOnManagerThread(() =>
            {
                if (Logger.IsDebug)
                {
                    var errorMessage = ex != null ? $" Error: {ex.Message}" : "";
                    Logger.Debug($"Transport state changed to: {transportState}.{errorMessage}");
                }

                if (transportState == TransportState.Closed || ex != null)
                {
                    var connectionState = _inTransitionToState?.State ?? ConnectionState;
                    switch (connectionState)
                    {
                    case Realtime.ConnectionState.Closing:
                        SetState(new ConnectionClosedState(this)
                        {
                            Exception = ex
                        });
                        break;

                    case Realtime.ConnectionState.Connecting:
                        HandleConnectingFailure(null, ex);
                        break;

                    case Realtime.ConnectionState.Connected:
                        var disconnectedState = new ConnectionDisconnectedState(this, GetErrorInfoFromTransportException(ex, ErrorInfo.ReasonDisconnected))
                        {
                            Exception = ex
                        };
                        disconnectedState.RetryInstantly = Connection.ConnectionResumable;
                        SetState(disconnectedState);
                        break;
                    }
                }

                return(TaskConstants.BooleanTrue);
            });
        }