Skip to content

Commit 73133c2

Browse files
committed
Exposing ReconnectInterval on ServerSentEventsServiceOptions. Resolves #37
1 parent b8c5194 commit 73133c2

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

Lib.AspNetCore.ServerSentEvents/Extensions/OptionsExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public static IOptions<ServerSentEventsServiceOptions<ServerSentEventsService>>
2929
{
3030
KeepaliveInterval = options.Value.KeepaliveInterval,
3131
KeepaliveMode = options.Value.KeepaliveMode,
32+
ReconnectInterval = options.Value.ReconnectInterval,
3233
OnClientConnected = options.Value.OnClientConnected,
3334
OnClientDisconnected = options.Value.OnClientDisconnected
3435
});

Lib.AspNetCore.ServerSentEvents/ServerSentEventsService.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ public class ServerSentEventsService : IServerSentEventsService
4343
public ServerSentEventsService(IOptions<ServerSentEventsServiceOptions<ServerSentEventsService>> options)
4444
{
4545
ServerSentEventsServiceOptions<ServerSentEventsService> serviceOptions = options?.Value;
46-
if ((serviceOptions != null) && ((serviceOptions.OnClientConnected != null) || (serviceOptions.OnClientDisconnected != null)))
46+
47+
if (serviceOptions != null)
4748
{
49+
ReconnectInterval = serviceOptions.ReconnectInterval;
50+
4851
if (serviceOptions.OnClientConnected != null)
4952
{
5053
ClientConnected += (sender, args) => serviceOptions.OnClientConnected((IServerSentEventsService)sender, args);

Lib.AspNetCore.ServerSentEvents/ServerSentEventsServiceOptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ public int KeepaliveInterval
3535
}
3636
}
3737

38+
/// <summary>
39+
/// Gets or sets the interval after which clients will attempt to reestablish failed connections.
40+
/// </summary>
41+
public uint? ReconnectInterval { get; set; } = null;
42+
3843
/// <summary>
3944
/// Called when client has connected.
4045
/// This can be used to add client to groups.

0 commit comments

Comments
 (0)