void OnAcceptTransport(TransportAsyncCallbackArgs args) { Fx.Assert(args.Exception == null, "Should not be failed."); Fx.Assert(args.Transport != null, "Should have a transport"); AmqpConnectionSettings settings = this.connectionSettings.Clone(); settings.OnOpenCallback = this.OnReceiveConnectionOpen; AmqpConnection connection = null; try { connection = this.CreateConnection( args.Transport, (ProtocolHeader)args.UserToken, false, this.amqpSettings.Clone(), settings); connection.BeginOpen(connection.DefaultOpenTimeout, this.onConnectionOpenComplete, connection); } catch (Exception ex) { if (Fx.IsFatal(ex)) { throw; } if (connection != null) { connection.TryClose(ExceptionHelper.ToAmqpException(ex)); } } }
void OnConnectionOpenComplete(IAsyncResult result) { AmqpConnection connection = (AmqpConnection)result.AsyncState; try { connection.EndOpen(result); this.HandleConnection(connection); } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } connection.TryClose(ExceptionHelper.ToAmqpException(exception)); } }