bool HandlePreambleAck()
                {
                    int ackBytesRead = connection.EndRead();

                    if (!ConnectionUpgradeHelper.ValidatePreambleResponse(
                            connection.AsyncReadBuffer, ackBytesRead, decoder, channel.Via))
                    {
                        if (onFailedUpgrade == null)
                        {
                            onFailedUpgrade = Fx.ThunkCallback(new AsyncCallback(OnFailedUpgrade));
                        }
                        IAsyncResult decodeFaultResult = ConnectionUpgradeHelper.BeginDecodeFramingFault(decoder,
                                                                                                         connection, channel.Via, channel.messageEncoder.ContentType, ref timeoutHelper,
                                                                                                         onFailedUpgrade, this);

                        if (!decodeFaultResult.CompletedSynchronously)
                        {
                            return(false);
                        }

                        ConnectionUpgradeHelper.EndDecodeFramingFault(decodeFaultResult);
                        return(true);
                    }

                    return(true);
                }
Example #2
0
            private bool HandlePreambleAck()
            {
                int count = this.connection.EndRead();

                if (!ConnectionUpgradeHelper.ValidatePreambleResponse(this.connection.AsyncReadBuffer, count, this.channel.decoder, this.channel.Via))
                {
                    IAsyncResult result = ConnectionUpgradeHelper.BeginDecodeFramingFault(this.channel.decoder, this.connection, this.channel.Via, this.channel.MessageEncoder.ContentType, ref this.timeoutHelper, Fx.ThunkCallback(new AsyncCallback(this.OnFailedPreamble)), this);
                    if (!result.CompletedSynchronously)
                    {
                        return(false);
                    }
                    ConnectionUpgradeHelper.EndDecodeFramingFault(result);
                }
                return(true);
            }
Example #3
0
                private bool HandlePreambleAck()
                {
                    int count = this.connection.EndRead();

                    if (!ConnectionUpgradeHelper.ValidatePreambleResponse(this.connection.AsyncReadBuffer, count, this.decoder, this.channel.Via))
                    {
                        if (onFailedUpgrade == null)
                        {
                            onFailedUpgrade = Fx.ThunkCallback(new AsyncCallback(StreamedFramingRequestChannel.StreamedConnectionPoolHelper.SendPreambleAsyncResult.OnFailedUpgrade));
                        }
                        IAsyncResult result = ConnectionUpgradeHelper.BeginDecodeFramingFault(this.decoder, this.connection, this.channel.Via, this.channel.messageEncoder.ContentType, ref this.timeoutHelper, onFailedUpgrade, this);
                        if (!result.CompletedSynchronously)
                        {
                            return(false);
                        }
                        ConnectionUpgradeHelper.EndDecodeFramingFault(result);
                    }
                    return(true);
                }
Example #4
0
            private bool CompleteReadUpgradeResponse()
            {
                int count = this.connection.EndRead();

                if (!ConnectionUpgradeHelper.ValidateUpgradeResponse(this.connection.AsyncReadBuffer, count, this.decoder))
                {
                    if (onFailedUpgrade == null)
                    {
                        onFailedUpgrade = Fx.ThunkCallback(new AsyncCallback(ConnectionUpgradeHelper.InitiateUpgradeAsyncResult.OnFailedUpgrade));
                    }
                    IAsyncResult result = ConnectionUpgradeHelper.BeginDecodeFramingFault(this.decoder, this.connection, this.remoteAddress.Uri, this.contentType, ref this.timeoutHelper, onFailedUpgrade, this);
                    if (result.CompletedSynchronously)
                    {
                        ConnectionUpgradeHelper.EndDecodeFramingFault(result);
                    }
                    return(result.CompletedSynchronously);
                }
                this.connectionStream = new ConnectionStream(this.connection, this.defaultTimeouts);
                IAsyncResult result2 = null;
                WindowsImpersonationContext context = (this.identityToImpersonate == null) ? null : this.identityToImpersonate.Impersonate();

                try
                {
                    using (context)
                    {
                        result2 = this.upgradeInitiator.BeginInitiateUpgrade(this.connectionStream, onInitiateUpgrade, this);
                    }
                }
                catch
                {
                    throw;
                }
                if (!result2.CompletedSynchronously)
                {
                    return(false);
                }
                this.CompleteUpgrade(result2);
                return(true);
            }