Exemplo n.º 1
0
        private Task OnConnectedAsyncCore(OpenConnectionMessage message)
        {
            var connectionId = message.ConnectionId;

            try
            {
                var transport = _clientConnectionManager.CreateConnection(message, this);
                _clientConnections.TryAdd(transport.ConnectionId, transport);
                Log.ConnectedStarting(_logger, connectionId);
                return(Task.CompletedTask);
            }
            catch (Exception e)
            {
                Log.ConnectedStartingFailed(_logger, connectionId, e);
                PerformDisconnectCore(connectionId);
                return(WriteAsync(new CloseConnectionMessage(connectionId, e.Message)));
            }
        }
Exemplo n.º 2
0
        private async Task OnConnectedAsyncCore(ClientConnectionContext clientContext, OpenConnectionMessage message)
        {
            var connectionId = message.ConnectionId;

            try
            {
                clientContext.Transport = await _clientConnectionManager.CreateConnection(message);

                Log.ConnectedStarting(Logger, connectionId);
            }
            catch (Exception e)
            {
                Log.ConnectedStartingFailed(Logger, connectionId, e);
                // Should not wait for application task inside the application task
                _ = PerformDisconnectCore(connectionId, false);
                _ = SafeWriteAsync(new CloseConnectionMessage(connectionId, e.Message));
            }
        }