Controller for receiving and sending messages to clients
IClientsController
is defined in the Telligent.Evolution.Extensibility.Sockets.Version1
namespace of Telligent.Evolution.Platform.dll
Definition
interface IClientsController { event EventHandler<UserConnectedEventArgs> Connected { add; remove; } event EventHandler<UserDisconnectedEventArgs> Disconnected { add; remove; } event EventHandler<MessageReceivedEventArgs> Received { add; remove; } void Broadcast(string messageName, Object data = null); Task BroadcastAsync(string messageName, Object data = null, CancellationToken cancellationToken = null); void Send(int userId, string messageName, Object data = null); Task SendAsync(int userId, string messageName, Object data = null, CancellationToken cancellationToken = null); void SendToUsersPresentToContent(Guid contentId, string messageName, Object data = null, Guid? presenceTypeId = null); void SendToUsersPresentToContent(string contentUrl, Guid oauthClientId, string messageName, Object data = null, Guid? presenceTypeId = null); Task SendToUsersPresentToContentAsync(Guid contentId, string messageName, Object data = null, Guid? presenceTypeId = null, CancellationToken cancellationToken = null); Task SendToUsersPresentToContentAsync(string contentUrl, Guid oauthClientId, string messageName, Object data = null, Guid? presenceTypeId = null, CancellationToken cancellationToken = null); void SendToUsersPresentToService(Guid serviceId, string messageName, Object data = null, Guid? presenceTypeId = null); Task SendToUsersPresentToServiceAsync(Guid serviceId, string messageName, Object data = null, Guid? presenceTypeId = null, CancellationToken cancellationToken = null); }
Events
Connected
Event raised when a user connects or reconnects after an interruption
Handler
void EventHandler<UserConnectedEventArgs>(Object sender, UserConnectedEventArgs e);
Disconnected
Event raised when a user disconnects
Handler
void EventHandler<UserDisconnectedEventArgs>(Object sender, UserDisconnectedEventArgs e);
Received
Event raised when a message is received from a user
Handler
void EventHandler<MessageReceivedEventArgs>(Object sender, MessageReceivedEventArgs e);
Methods
void Broadcast(string messageName, Object data = null);
Sends a message to all users, along with optional message data to serialize as JSON
Parameters
Name | Type | Description | Required | Default | Options |
---|---|---|---|---|---|
messageName | string | Message Name | Required | ||
data | Object | Data | Optional |
Task BroadcastAsync(string messageName, Object data = null, CancellationToken cancellationToken = null);
Sends a message to all users, along with optional message data to serialize as JSON
Parameters
Name | Type | Description | Required | Default | Options |
---|---|---|---|---|---|
messageName | string | Message Name | Required | ||
data | Object | Data | Optional | ||
cancellationToken | CancellationToken | Cancellation Token | Optional |
Return Type
Task
void Send(int userId, string messageName, Object data = null);
Sends a message to a specific user, along with optional message data to serialize as JSON
Parameters
Name | Type | Description | Required | Default | Options |
---|---|---|---|---|---|
userId | int | User Id | Required | ||
messageName | string | Message Name | Required | ||
data | Object | Data | Optional |
Task SendAsync(int userId, string messageName, Object data = null, CancellationToken cancellationToken = null);
Sends a message to a specific user, along with optional message data to serialize as JSON
Parameters
Name | Type | Description | Required | Default | Options |
---|---|---|---|---|---|
userId | int | User Id | Required | ||
messageName | string | Message Name | Required | ||
data | Object | Data | Optional | ||
cancellationToken | CancellationToken | Cancellation Token | Optional |
Return Type
Task
void SendToUsersPresentToContent(Guid contentId, string messageName, Object data = null, Guid? presenceTypeId = null);
Sends a message to users present to a specific piece of content, along with optional message data to serialize as JSON
Parameters
Name | Type | Description | Required | Default | Options |
---|---|---|---|---|---|
contentId | Guid | Content Id | Required | ||
messageName | string | Message Name | Required | ||
data | Object | Data | Optional | ||
presenceTypeId | Guid? | Presence Type Id | Optional |
void SendToUsersPresentToContent(string contentUrl, Guid oauthClientId, string messageName, Object data = null, Guid? presenceTypeId = null);
Sends a message to users present to a specific piece of content, along with optional message data to serialize as JSON
Parameters
Name | Type | Description | Required | Default | Options |
---|---|---|---|---|---|
contentUrl | string | Content Url | Required | ||
oauthClientId | Guid | Oauth Client Id | Required | ||
messageName | string | Message Name | Required | ||
data | Object | Data | Optional | ||
presenceTypeId | Guid? | Presence Type Id | Optional |
Task SendToUsersPresentToContentAsync(Guid contentId, string messageName, Object data = null, Guid? presenceTypeId = null, CancellationToken cancellationToken = null);
Sends a message to users present to a specific piece of content, along with optional message data to serialize as JSON
Parameters
Name | Type | Description | Required | Default | Options |
---|---|---|---|---|---|
contentId | Guid | Content Id | Required | ||
messageName | string | Message Name | Required | ||
data | Object | Data | Optional | ||
presenceTypeId | Guid? | Presence Type Id | Optional | ||
cancellationToken | CancellationToken | Cancellation Token | Optional |
Return Type
Task
Task SendToUsersPresentToContentAsync(string contentUrl, Guid oauthClientId, string messageName, Object data = null, Guid? presenceTypeId = null, CancellationToken cancellationToken = null);
Sends a message to users present to a specific piece of content, along with optional message data to serialize as JSON
Parameters
Name | Type | Description | Required | Default | Options |
---|---|---|---|---|---|
contentUrl | string | Content Url | Required | ||
oauthClientId | Guid | Oauth Client Id | Required | ||
messageName | string | Message Name | Required | ||
data | Object | Data | Optional | ||
presenceTypeId | Guid? | Presence Type Id | Optional | ||
cancellationToken | CancellationToken | Cancellation Token | Optional |
Return Type
Task
void SendToUsersPresentToService(Guid serviceId, string messageName, Object data = null, Guid? presenceTypeId = null);
Sends a message to users present to a specific service, along with optional message data to serialize as JSON
Parameters
Name | Type | Description | Required | Default | Options |
---|---|---|---|---|---|
serviceId | Guid | Service Id | Required | ||
messageName | string | Message Name | Required | ||
data | Object | Data | Optional | ||
presenceTypeId | Guid? | Presence Type Id | Optional |
Task SendToUsersPresentToServiceAsync(Guid serviceId, string messageName, Object data = null, Guid? presenceTypeId = null, CancellationToken cancellationToken = null);
Sends a message to users present to a specific service, along with optional message data to serialize as JSON
Parameters
Name | Type | Description | Required | Default | Options |
---|---|---|---|---|---|
serviceId | Guid | Service Id | Required | ||
messageName | string | Message Name | Required | ||
data | Object | Data | Optional | ||
presenceTypeId | Guid? | Presence Type Id | Optional | ||
cancellationToken | CancellationToken | Cancellation Token | Optional |
Return Type
Task