Skip to content

Commit

Permalink
Add RetryOptions, RetryMode and MaxRetryAttempts
Browse files Browse the repository at this point in the history
  • Loading branch information
carlst99 committed Apr 16, 2018
1 parent 913b2c4 commit fd67e2c
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/Ether.Network/Client/NetClientConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@

namespace Ether.Network.Client
{
/// <summary>
/// Options defining how a client will handle a failed connection attempt
/// </summary>
public enum ClientRetryOptions
{
/// <summary>
/// The client will only try to connect one time
/// </summary>
OneTime = 0,

/// <summary>
/// The client will try to connect up to the amount of times specified by <see cref="MaxRetryAttempts"/>
/// </summary>
ToLimit = 1,

/// <summary>
/// The client will try infinitely to connect to the server
/// </summary>
Infinite = 2
}

/// <summary>
/// Provides properties to configure a <see cref="NetClient"/>.
/// </summary>
Expand All @@ -14,6 +35,8 @@ public sealed class NetClientConfiguration
private int _bufferSize;
private string _host;
private int _timeOut;
private ClientRetryOptions _retryMode;
private int _maxRetryAttempts;

/// <summary>
/// Gets or sets the port.
Expand Down Expand Up @@ -51,6 +74,25 @@ public int TimeOut
set => this.SetValue(ref this._timeOut, value);
}

/// <summary>
/// Gets or sets how the client handles failed connections.
/// When using <see cref="ClientRetryOptions.ToLimit"/> set <see cref="MaxRetryAttempts"/>
/// </summary>
public ClientRetryOptions RetryMode
{
get => this._retryMode;
set => this.SetValue(ref this._retryMode, value);
}

/// <summary>
/// Gets or sets the maximum number of times the client will try to reconnect to the server
/// </summary>
public int MaxRetryAttempts
{
get => this._maxRetryAttempts;
set => this.SetValue(ref this._maxRetryAttempts, value);
}

/// <summary>
/// Gets the listening address.
/// </summary>
Expand Down

0 comments on commit fd67e2c

Please sign in to comment.