Esempio n. 1
0
        public string GetHost()
        {
            var    lastFailedState = Attempts.SelectMany(x => x.FailedStates).LastOrDefault(x => x.ShouldUseFallback());
            string customHost      = "";

            if (lastFailedState != null)
            {
                if (lastFailedState.State == ConnectionState.Disconnected)
                {
                    customHost = _connection.FallbackHosts[DisconnectedCount % _connection.FallbackHosts.Count];
                }
                if (lastFailedState.State == ConnectionState.Suspended && SuspendedCount > 1)
                {
                    customHost =
                        _connection.FallbackHosts[(DisconnectedCount + SuspendedCount) % _connection.FallbackHosts.Count];
                }

                if (customHost.IsNotEmpty())
                {
                    _connection.Host = customHost;
                    return(customHost);
                }
            }

            _connection.Host = Options.FullRealtimeHost();
            return(_connection.Host);
        }
Esempio n. 2
0
 public int SuspendedCount() => Attempts.SelectMany(x => x.FailedStates)
 .Count(x => x.State == ConnectionState.Suspended);
Esempio n. 3
0
 public int DisconnectedCount() => Attempts.SelectMany(x => x.FailedStates)
 .Count(x => x.State == ConnectionState.Disconnected && x.ShouldUseFallback());