예제 #1
0
        private async Task AcceptAsync(ITransmissionConnection c)
        {
            try
            {
                await _buffer.WriteAsync(_connectionFactory.Create(c), CancellationToken).ConfigureAwait(false);

                Log.Debug("New connection accepted");
            }
            catch
            {
                await c.DisconnectAsync().IgnoreExceptions().ConfigureAwait(false);

                throw;
            }
        }
예제 #2
0
        public async ValueTask <ITransportConnection> ConnectAsync(string brokerWorkingDir, CancellationToken cancellationToken)
        {
            var transmissionConnection = await _transmissionClient.ConnectAsync(brokerWorkingDir, cancellationToken).ConfigureAwait(false);

            try
            {
                return(_connectionFactory.Create(transmissionConnection));
            }
            catch (OperationCanceledException) when(cancellationToken.IsCancellationRequested)
            {
                Log.Trace("Connection canceled");
                transmissionConnection.Dispose();
                throw;
            }
            catch (Exception ex)
            {
                Log.Trace("Connection failed: {0}", ex.FormatTypeAndMessage());
                transmissionConnection.Dispose();
                throw;
            }
        }