Udostępnij przez


WebPubSubHub.OnConnectAsync(ConnectEventRequest, CancellationToken) Method

Definition

Connect event method.

public virtual System.Threading.Tasks.ValueTask<Microsoft.Azure.WebPubSub.Common.ConnectEventResponse> OnConnectAsync(Microsoft.Azure.WebPubSub.Common.ConnectEventRequest request, System.Threading.CancellationToken cancellationToken);
abstract member OnConnectAsync : Microsoft.Azure.WebPubSub.Common.ConnectEventRequest * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<Microsoft.Azure.WebPubSub.Common.ConnectEventResponse>
override this.OnConnectAsync : Microsoft.Azure.WebPubSub.Common.ConnectEventRequest * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<Microsoft.Azure.WebPubSub.Common.ConnectEventResponse>
Public Overridable Function OnConnectAsync (request As ConnectEventRequest, cancellationToken As CancellationToken) As ValueTask(Of ConnectEventResponse)

Parameters

request
ConnectEventRequest

ConnectEventRequest to get client connect request information.

For MQTT clients, you can get MQTT specified information like MQTT protocol version, username, password, and user property fields in the MQTT CONNECT packet by casting the "request" parameter to MqttConnectEventRequest type.

cancellationToken
CancellationToken

The CancellationToken used to cancel the request.

Returns

Build a valid ConnectEventResponse with ConnectEventRequest.CreateResponse().

Throw UnauthorizedAccessException or AuthenticationException will result 401 Status401Unauthorized status with user assigned error messages.

Throw MqttConnectionException to control the MQTT return code/reason code to the client, and user properties.

Throw other exceptions will result 500 Status500InternalServerError with user assigned error messages.

Applies to