Interface IServerSentEventsService
Contract for service which provides operations over Server-Sent Events protocol.
Namespace: Lib.AspNetCore.ServerSentEvents
Assembly: Lib.AspNetCore.ServerSentEvents.dll
Syntax
public interface IServerSentEventsService
  Properties
ReconnectInterval
Gets the interval after which clients will attempt to reestablish failed connections.
Declaration
uint? ReconnectInterval { get; }
  Property Value
| Type | Description | 
|---|---|
| System.Nullable<System.UInt32> | 
Methods
AddToGroup(String, IServerSentEventsClient)
Adds a client to the specified group.
Declaration
ServerSentEventsAddToGroupResult AddToGroup(string groupName, IServerSentEventsClient client)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | groupName | The group name.  | 
      
| IServerSentEventsClient | client | The client to add to a group.  | 
      
Returns
| Type | Description | 
|---|---|
| ServerSentEventsAddToGroupResult | The result of operation.  | 
      
ChangeReconnectIntervalAsync(UInt32)
Changes the interval after which clients will attempt to reestablish failed connections.
Declaration
Task ChangeReconnectIntervalAsync(uint reconnectInterval)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.UInt32 | reconnectInterval | The reconnect interval.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task | The task object representing the asynchronous operation.  | 
      
ChangeReconnectIntervalAsync(UInt32, CancellationToken)
Changes the interval after which clients will attempt to reestablish failed connections.
Declaration
Task ChangeReconnectIntervalAsync(uint reconnectInterval, CancellationToken cancellationToken)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.UInt32 | reconnectInterval | The reconnect interval.  | 
      
| System.Threading.CancellationToken | cancellationToken | The cancellation token to cancel operation.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task | The task object representing the asynchronous operation.  | 
      
GetClient(Guid)
Gets the client based on the unique client identifier.
Declaration
IServerSentEventsClient GetClient(Guid clientId)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Guid | clientId | The unique client identifier.  | 
      
Returns
| Type | Description | 
|---|---|
| IServerSentEventsClient | The client.  | 
      
GetClients()
Gets all clients.
Declaration
IReadOnlyCollection<IServerSentEventsClient> GetClients()
  Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IReadOnlyCollection<IServerSentEventsClient> | The clients.  | 
      
GetClients(String)
Gets clients in the specified group.
Declaration
IReadOnlyCollection<IServerSentEventsClient> GetClients(string groupName)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | groupName | The group name.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IReadOnlyCollection<IServerSentEventsClient> | The clients in the specified group.  | 
      
OnConnectAsync(HttpRequest, IServerSentEventsClient)
Method which is called when client is establishing the connection. The base implementation raises the ClientConnected event.
Declaration
Task OnConnectAsync(HttpRequest request, IServerSentEventsClient client)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Microsoft.AspNetCore.Http.HttpRequest | request | The request which has been made in order to establish the connection.  | 
      
| IServerSentEventsClient | client | The client who is establishing the connection.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task | The task object representing the asynchronous operation.  | 
      
OnDisconnectAsync(HttpRequest, IServerSentEventsClient)
Method which is called when client is disconnecting. The base implementation raises the ClientDisconnected event.
Declaration
Task OnDisconnectAsync(HttpRequest request, IServerSentEventsClient client)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Microsoft.AspNetCore.Http.HttpRequest | request | The original request which has been made in order to establish the connection.  | 
      
| IServerSentEventsClient | client | The client who is disconnecting.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task | The task object representing the asynchronous operation.  | 
      
OnReconnectAsync(HttpRequest, IServerSentEventsClient, String)
Method which is called when client is reestablishing the connection. The base implementation raises the ClientConnected event.
Declaration
Task OnReconnectAsync(HttpRequest request, IServerSentEventsClient client, string lastEventId)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Microsoft.AspNetCore.Http.HttpRequest | request | The request which has been made in order to establish the connection.  | 
      
| IServerSentEventsClient | client | The client who is reestablishing the connection.  | 
      
| System.String | lastEventId | The identifier of last event which client has received.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task | The task object representing the asynchronous operation.  | 
      
SendEventAsync(ServerSentEvent)
Sends event to all clients.
Declaration
Task SendEventAsync(ServerSentEvent serverSentEvent)
  Parameters
| Type | Name | Description | 
|---|---|---|
| ServerSentEvent | serverSentEvent | The event.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task | The task object representing the asynchronous operation.  | 
      
SendEventAsync(ServerSentEvent, Func<IServerSentEventsClient, Boolean>)
Sends event to all clients.
Declaration
Task SendEventAsync(ServerSentEvent serverSentEvent, Func<IServerSentEventsClient, bool> clientPredicate)
  Parameters
| Type | Name | Description | 
|---|---|---|
| ServerSentEvent | serverSentEvent | The event.  | 
      
| System.Func<IServerSentEventsClient, System.Boolean> | clientPredicate | The function to test each client for a condition.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task | The task object representing the asynchronous operation.  | 
      
SendEventAsync(ServerSentEvent, Func<IServerSentEventsClient, Boolean>, CancellationToken)
Sends event to all clients.
Declaration
Task SendEventAsync(ServerSentEvent serverSentEvent, Func<IServerSentEventsClient, bool> clientPredicate, CancellationToken cancellationToken)
  Parameters
| Type | Name | Description | 
|---|---|---|
| ServerSentEvent | serverSentEvent | The event.  | 
      
| System.Func<IServerSentEventsClient, System.Boolean> | clientPredicate | The function to test each client for a condition.  | 
      
| System.Threading.CancellationToken | cancellationToken | The cancellation token to cancel operation.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task | The task object representing the asynchronous operation.  | 
      
SendEventAsync(ServerSentEvent, CancellationToken)
Sends event to all clients.
Declaration
Task SendEventAsync(ServerSentEvent serverSentEvent, CancellationToken cancellationToken)
  Parameters
| Type | Name | Description | 
|---|---|---|
| ServerSentEvent | serverSentEvent | The event.  | 
      
| System.Threading.CancellationToken | cancellationToken | The cancellation token to cancel operation.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task | The task object representing the asynchronous operation.  | 
      
SendEventAsync(String)
Sends event to all clients.
Declaration
Task SendEventAsync(string text)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | text | The simple text event.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task | The task object representing the asynchronous operation.  | 
      
SendEventAsync(String, ServerSentEvent)
Sends event to clients in group.
Declaration
Task SendEventAsync(string groupName, ServerSentEvent serverSentEvent)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | groupName | The group name.  | 
      
| ServerSentEvent | serverSentEvent | The event.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task | The task object representing the asynchronous operation.  | 
      
SendEventAsync(String, ServerSentEvent, Func<IServerSentEventsClient, Boolean>)
Sends event to clients in group.
Declaration
Task SendEventAsync(string groupName, ServerSentEvent serverSentEvent, Func<IServerSentEventsClient, bool> clientPredicate)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | groupName | The group name.  | 
      
| ServerSentEvent | serverSentEvent | The event.  | 
      
| System.Func<IServerSentEventsClient, System.Boolean> | clientPredicate | The function to test each client for a condition.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task | The task object representing the asynchronous operation.  | 
      
SendEventAsync(String, ServerSentEvent, Func<IServerSentEventsClient, Boolean>, CancellationToken)
Sends event to clients in group.
Declaration
Task SendEventAsync(string groupName, ServerSentEvent serverSentEvent, Func<IServerSentEventsClient, bool> clientPredicate, CancellationToken cancellationToken)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | groupName | The group name.  | 
      
| ServerSentEvent | serverSentEvent | The event.  | 
      
| System.Func<IServerSentEventsClient, System.Boolean> | clientPredicate | The function to test each client for a condition.  | 
      
| System.Threading.CancellationToken | cancellationToken | The cancellation token to cancel operation.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task | The task object representing the asynchronous operation.  | 
      
SendEventAsync(String, ServerSentEvent, CancellationToken)
Sends event to clients in group.
Declaration
Task SendEventAsync(string groupName, ServerSentEvent serverSentEvent, CancellationToken cancellationToken)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | groupName | The group name.  | 
      
| ServerSentEvent | serverSentEvent | The event.  | 
      
| System.Threading.CancellationToken | cancellationToken | The cancellation token to cancel operation.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task | The task object representing the asynchronous operation.  | 
      
SendEventAsync(String, Func<IServerSentEventsClient, Boolean>)
Sends event to all clients.
Declaration
Task SendEventAsync(string text, Func<IServerSentEventsClient, bool> clientPredicate)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | text | The simple text event.  | 
      
| System.Func<IServerSentEventsClient, System.Boolean> | clientPredicate | The function to test each client for a condition.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task | The task object representing the asynchronous operation.  | 
      
SendEventAsync(String, Func<IServerSentEventsClient, Boolean>, CancellationToken)
Sends event to all clients.
Declaration
Task SendEventAsync(string text, Func<IServerSentEventsClient, bool> clientPredicate, CancellationToken cancellationToken)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | text | The simple text event.  | 
      
| System.Func<IServerSentEventsClient, System.Boolean> | clientPredicate | The function to test each client for a condition.  | 
      
| System.Threading.CancellationToken | cancellationToken | The cancellation token to cancel operation.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task | The task object representing the asynchronous operation.  | 
      
SendEventAsync(String, String)
Sends event to clients in group.
Declaration
Task SendEventAsync(string groupName, string text)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | groupName | The group name.  | 
      
| System.String | text | The simple text event.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task | The task object representing the asynchronous operation.  | 
      
SendEventAsync(String, String, Func<IServerSentEventsClient, Boolean>)
Sends event to clients in group.
Declaration
Task SendEventAsync(string groupName, string text, Func<IServerSentEventsClient, bool> clientPredicate)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | groupName | The group name.  | 
      
| System.String | text | The simple text event.  | 
      
| System.Func<IServerSentEventsClient, System.Boolean> | clientPredicate | The function to test each client for a condition.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task | The task object representing the asynchronous operation.  | 
      
SendEventAsync(String, String, Func<IServerSentEventsClient, Boolean>, CancellationToken)
Sends event to clients in group.
Declaration
Task SendEventAsync(string groupName, string text, Func<IServerSentEventsClient, bool> clientPredicate, CancellationToken cancellationToken)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | groupName | The group name.  | 
      
| System.String | text | The simple text event.  | 
      
| System.Func<IServerSentEventsClient, System.Boolean> | clientPredicate | The function to test each client for a condition.  | 
      
| System.Threading.CancellationToken | cancellationToken | The cancellation token to cancel operation.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task | The task object representing the asynchronous operation.  | 
      
SendEventAsync(String, String, CancellationToken)
Sends event to clients in group.
Declaration
Task SendEventAsync(string groupName, string text, CancellationToken cancellationToken)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | groupName | The group name.  | 
      
| System.String | text | The simple text event.  | 
      
| System.Threading.CancellationToken | cancellationToken | The cancellation token to cancel operation.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task | The task object representing the asynchronous operation.  | 
      
SendEventAsync(String, CancellationToken)
Sends event to all clients.
Declaration
Task SendEventAsync(string text, CancellationToken cancellationToken)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | text | The simple text event.  | 
      
| System.Threading.CancellationToken | cancellationToken | The cancellation token to cancel operation.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task | The task object representing the asynchronous operation.  | 
      
Events
ClientConnected
Occurs when client has connected.
Declaration
event EventHandler<ServerSentEventsClientConnectedArgs> ClientConnected
  Event Type
| Type | Description | 
|---|---|
| System.EventHandler<ServerSentEventsClientConnectedArgs> | 
ClientDisconnected
Occurs when client has disconnected.
Declaration
event EventHandler<ServerSentEventsClientDisconnectedArgs> ClientDisconnected
  Event Type
| Type | Description | 
|---|---|
| System.EventHandler<ServerSentEventsClientDisconnectedArgs> |