コード例 #1
0
        public async Task HandleAsync(
            IWebSocketContext context,
            GenericOperationMessage message,
            CancellationToken cancellationToken)
        {
            ConnectionStatus connectionStatus =
                await context.OpenAsync(message.Payload.ToDictionary())
                .ConfigureAwait(false);

            if (connectionStatus.Accepted)
            {
                await context.SendConnectionAcceptMessageAsync(
                    cancellationToken).ConfigureAwait(false);

                await context.SendConnectionKeepAliveMessageAsync(
                    cancellationToken).ConfigureAwait(false);
            }
            else
            {
                await context.SendConnectionErrorMessageAsync(
                    connectionStatus.Response, cancellationToken)
                .ConfigureAwait(false);

                await context.CloseAsync().ConfigureAwait(false);
            }
        }
コード例 #2
0
        public async Task HandleAsync(
            IWebSocketContext context,
            GenericOperationMessage message,
            CancellationToken cancellationToken)
        {
            await context.SendConnectionAcceptMessageAsync(
                cancellationToken);

            await context.SendConnectionKeepAliveMessageAsync(
                cancellationToken);
        }