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 |
---|---|
System.Guid |
IsConnected
Gets the value indicating if client is connected.
Declaration
bool IsConnected { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
User
Gets the System.Security.Claims.ClaimsPrincipal for user associated with the client.
Declaration
ClaimsPrincipal User { get; }
Property Value
Type | Description |
---|---|
System.Security.Claims.ClaimsPrincipal |
Methods
DisconnectAsync()
Disconnects client.
Declaration
Task DisconnectAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.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 |
---|---|---|
System.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 |
---|---|---|
System.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 |
---|---|
System.Threading.Tasks.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. |
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 client.
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, CancellationToken)
Sends event to client.
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. |
SetProperty(String, Object, Boolean)
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 |
---|---|---|
System.String | name | The name of the property being added. |
System.Object | value | The value of the property being added. |
System.Boolean | 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 |
---|---|
System.Boolean | True if the property has been added or updated, false otherwise. |