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); }
public int SuspendedCount() => Attempts.SelectMany(x => x.FailedStates) .Count(x => x.State == ConnectionState.Suspended);
public int DisconnectedCount() => Attempts.SelectMany(x => x.FailedStates) .Count(x => x.State == ConnectionState.Disconnected && x.ShouldUseFallback());