Initial Commit ...
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
using xPushService.Configurations;
|
||||
|
||||
namespace xPushService.Policies {
|
||||
public class XPushServiceConnectionRetryPolicy : IRetryPolicy {
|
||||
//
|
||||
#region Props ...
|
||||
//
|
||||
Exception retryReason = null;
|
||||
long previousRetryCount = 0;
|
||||
TimeSpan elapsedMilliseconds;
|
||||
|
||||
//
|
||||
private readonly XPushServiceConfiguration config;
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Constructor ...
|
||||
public XPushServiceConnectionRetryPolicy (
|
||||
XPushServiceConfiguration config
|
||||
) {
|
||||
this.config = config;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public TimeSpan? NextRetryDelay (RetryContext retryContext) {
|
||||
//
|
||||
this.retryReason = retryContext.RetryReason;
|
||||
this.previousRetryCount = retryContext.PreviousRetryCount;
|
||||
this.elapsedMilliseconds = retryContext.ElapsedTime;
|
||||
|
||||
//
|
||||
if (retryContext.PreviousRetryCount < config.PushConnectionMaxRetry) {
|
||||
return TimeSpan.FromMilliseconds (this.config.PushConnectionReconnectDelay);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user