Пример #1
0
 public PresenceService(Options?options,
                        IAuthService authService, ISessionResolver sessionResolver, ILogger <PresenceService>?log = null)
 {
     options         = options.OrDefault();
     Log             = log ??= NullLogger <PresenceService> .Instance;
     AuthService     = authService;
     SessionResolver = sessionResolver;
     UpdateDelayer   = new UpdateDelayer(new UpdateDelayer.Options()
     {
         Delay             = options.UpdatePeriod,
         CancellationDelay = TimeSpan.Zero,
     });
 }
Пример #2
0
        protected override async Task RunInternalAsync(CancellationToken cancellationToken)
        {
            var session = await SessionResolver.GetSessionAsync(cancellationToken).ConfigureAwait(false);

            var retryCount = 0;

            while (!cancellationToken.IsCancellationRequested)
            {
                await UpdateDelayer.DelayAsync(retryCount, cancellationToken).ConfigureAwait(false);

                var success = await UpdatePresenceAsync(session, cancellationToken).ConfigureAwait(false);

                retryCount = success ? 0 : 1 + retryCount;
            }
        }
Пример #3
0
 public virtual void UpdatePresence() => UpdateDelayer.CancelDelays();