示例#1
0
        internal static async Task <IAsyncTransport> OpenAsync(this SaslProfile saslProfile, string hostname,
                                                               IBufferManager bufferManager, IAsyncTransport transport, DescribedList command)
        {
            // if transport is closed, pump reader should throw exception
            TransportWriter writer = new TransportWriter(transport, e => { });

            ProtocolHeader myHeader = saslProfile.Start(writer, command);

            AsyncPump pump = new AsyncPump(bufferManager, transport);
            SaslCode  code = SaslCode.Auth;

            await pump.PumpAsync(
                SaslProfile.MaxFrameSize,
                header =>
            {
                saslProfile.OnHeader(myHeader, header);
                return(true);
            },
                buffer =>
            {
                return(saslProfile.OnFrame(hostname, writer, buffer, out code));
            }).ConfigureAwait(false);

            await writer.FlushAsync().ConfigureAwait(false);

            if (code != SaslCode.Ok)
            {
                throw new AmqpException(ErrorCode.UnauthorizedAccess,
                                        Fx.Format(SRAmqp.SaslNegoFailed, code));
            }

            return((IAsyncTransport)saslProfile.UpgradeTransportInternal(transport));
        }
示例#2
0
        internal static async Task <IAsyncTransport> OpenAsync(this SaslProfile saslProfile, string hostname,
                                                               IBufferManager bufferManager, IAsyncTransport transport)
        {
            // if transport is closed, pump reader should throw exception
            TransportWriter writer = new TransportWriter(transport, e => { });

            ProtocolHeader myHeader = saslProfile.Start(hostname, writer);

            AsyncPump pump = new AsyncPump(bufferManager, transport);

            await pump.PumpAsync(
                header =>
            {
                saslProfile.OnHeader(myHeader, header);
                return(true);
            },
                buffer =>
            {
                SaslCode code;
                return(saslProfile.OnFrame(writer, buffer, out code));
            });

            await writer.FlushAsync();

            return((IAsyncTransport)saslProfile.UpgradeTransportInternal(transport));
        }
示例#3
0
 public CloseByteBuffer(TransportWriter writer)
     : base(null, 0, 0, 0)
 {
     this.writer = writer;
 }
示例#4
0
        internal static async Task<IAsyncTransport> OpenAsync(this SaslProfile saslProfile, string hostname,
            IBufferManager bufferManager, IAsyncTransport transport)
        {
            // if transport is closed, pump reader should throw exception
            TransportWriter writer = new TransportWriter(transport, e => { });

            ProtocolHeader myHeader = saslProfile.Start(hostname, writer);

            AsyncPump pump = new AsyncPump(bufferManager, transport);
            SaslCode code = SaslCode.Auth;

            await pump.PumpAsync(
                header =>
                {
                    saslProfile.OnHeader(myHeader, header);
                    return true;
                },
                buffer =>
                {
                    return saslProfile.OnFrame(writer, buffer, out code);
                });

            await writer.FlushAsync();

            if (code != SaslCode.Ok)
            {
                throw new AmqpException(ErrorCode.UnauthorizedAccess,
                    Fx.Format(SRAmqp.SaslNegoFailed, code));
            }

            return (IAsyncTransport)saslProfile.UpgradeTransportInternal(transport);
        }
示例#5
0
        internal static async Task<IAsyncTransport> OpenAsync(this SaslProfile saslProfile, string hostname,
            IBufferManager bufferManager, IAsyncTransport transport)
        {
            // if transport is closed, pump reader should throw exception
            TransportWriter writer = new TransportWriter(transport, e => { });

            ProtocolHeader myHeader = saslProfile.Start(hostname, writer);

            AsyncPump pump = new AsyncPump(bufferManager, transport);

            await pump.PumpAsync(
                header =>
                {
                    saslProfile.OnHeader(myHeader, header);
                    return true;
                },
                buffer =>
                {
                    SaslCode code;
                    return saslProfile.OnFrame(writer, buffer, out code);
                });

            await writer.FlushAsync();

            return (IAsyncTransport)saslProfile.UpgradeTransportInternal(transport);
        }
示例#6
0
 public CloseByteBuffer(TransportWriter writer)
     : base(null, 0, 0, 0)
 {
     this.writer = writer;
 }