Interface IServerSentEventsClient
Contract for client listening for Server-Sent Events
Namespace: Lib.AspNetCore.ServerSentEvents
Assembly: Lib.AspNetCore.ServerSentEvents.dll
Syntax
public interface IServerSentEventsClient
Properties
Id
Gets the unique client identifier.
Declaration
Guid Id { get; }
Property Value
| Type | Description |
|---|---|
| Guid |
IsConnected
Gets the value indicating if client is connected.
Declaration
bool IsConnected { get; }
Property Value
| Type | Description |
|---|---|
| bool |
User
Gets the System.Security.Claims.ClaimsPrincipal for user associated with the client.
Declaration
ClaimsPrincipal User { get; }
Property Value
| Type | Description |
|---|---|
| ClaimsPrincipal |
Methods
DisconnectAsync()
Disconnects client.
Declaration
Task DisconnectAsync()
Returns
| Type | Description |
|---|---|
| Task |
Remarks
This requires registering implementations of IServerSentEventsClientIdProvider and IServerSentEventsNoReconnectClientsIdsStore.
GetProperty<T>(string)
Retrieves a piece of information associated to this client.
Declaration
T GetProperty<T>(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the property being retrieved. |
Returns
| Type | Description |
|---|---|
| T | The value of the property whose name has been specified if it exists in the set of properties associated to the client. Default otherwise. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the property being retrieved. |
RemoveProperty<T>(string)
Removes a piece of information associated to this client.
Declaration
T RemoveProperty<T>(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the property being removed. |
Returns
| Type | Description |
|---|---|
| T | The value of the property whose name has been specified if it exists in the set of properties associated to the client. Default otherwise. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the property being removed. |
SendEventAsync(ServerSentEvent)
Sends event to client.
Declaration
Task SendEventAsync(ServerSentEvent serverSentEvent)
Parameters
| Type | Name | Description |
|---|---|---|
| ServerSentEvent | serverSentEvent | The event. |
Returns
| Type | Description |
|---|---|
| Task | The task object representing the asynchronous operation. |
SendEventAsync(ServerSentEvent, CancellationToken)
Sends event to client.
Declaration
Task SendEventAsync(ServerSentEvent serverSentEvent, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| ServerSentEvent | serverSentEvent | The event. |
| CancellationToken | cancellationToken | The cancellation token to cancel operation. |
Returns
| Type | Description |
|---|---|
| Task | The task object representing the asynchronous operation. |
SendEventAsync(string)
Sends event to client.
Declaration
Task SendEventAsync(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The simple text event. |
Returns
| Type | Description |
|---|---|
| Task | The task object representing the asynchronous operation. |
SendEventAsync(string, CancellationToken)
Sends event to client.
Declaration
Task SendEventAsync(string text, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The simple text event. |
| CancellationToken | cancellationToken | The cancellation token to cancel operation. |
Returns
| Type | Description |
|---|---|
| Task | The task object representing the asynchronous operation. |
SetProperty(string, object, bool)
Adds a property to the client so that it can be used to store client related pieces of information.
Declaration
bool SetProperty(string name, object value, bool overwrite = false)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the property being added. |
| object | value | The value of the property being added. |
| bool | overwrite | When true and the property already exists, its value will be updated. When false and the property already exists, its value will not be updated. |
Returns
| Type | Description |
|---|---|
| bool | True if the property has been added or updated, false otherwise. |