private bool HandleInitiatorOpen(IAsyncResult result) { Type type = this.upgradeInitiator.GetType(); StreamUpgradeInitiator streamUpgradeInitiator = this.upgradeInitiator; object[] objArray = new object[] { result }; InvokeHelper.InvokeInstanceMethod(type, streamUpgradeInitiator, "EndOpen", objArray); if (Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.SendPreambleAsyncResult.onUpgrade == null) { Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.SendPreambleAsyncResult.onUpgrade = Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ThunkAsyncCallback(new AsyncCallback(Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.SendPreambleAsyncResult.OnUpgrade)); } IAsyncResult asyncResult = Microsoft.ServiceBus.Channels.ConnectionUpgradeHelper.BeginInitiateUpgrade(this.channel, this.channel.RemoteAddress, this.connection, this.channel.decoder, this.upgradeInitiator, this.channel.MessageEncoder.ContentType, this.timeoutHelper, Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.SendPreambleAsyncResult.onUpgrade, this); if (!asyncResult.CompletedSynchronously) { return(false); } return(this.HandleUpgrade(asyncResult)); }
private bool HandleWritePreamble(IAsyncResult result) { this.connection.EndWrite(result); if (this.channel.upgrade == null) { return(this.ReadPreambleAck()); } this.upgradeInitiator = this.channel.upgrade.CreateUpgradeInitiator(this.channel.RemoteAddress, this.channel.Via); if (Microsoft.ServiceBus.Channels.StreamedFramingRequestChannel.StreamedConnectionPoolHelper.SendPreambleAsyncResult.onUpgrade == null) { Microsoft.ServiceBus.Channels.StreamedFramingRequestChannel.StreamedConnectionPoolHelper.SendPreambleAsyncResult.onUpgrade = Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ThunkAsyncCallback(new AsyncCallback(Microsoft.ServiceBus.Channels.StreamedFramingRequestChannel.StreamedConnectionPoolHelper.SendPreambleAsyncResult.OnUpgrade)); } IAsyncResult asyncResult = Microsoft.ServiceBus.Channels.ConnectionUpgradeHelper.BeginInitiateUpgrade(this.channel.settings, this.channel.RemoteAddress, this.connection, this.decoder, this.upgradeInitiator, this.channel.messageEncoder.ContentType, this.timeoutHelper, Microsoft.ServiceBus.Channels.StreamedFramingRequestChannel.StreamedConnectionPoolHelper.SendPreambleAsyncResult.onUpgrade, this); if (!asyncResult.CompletedSynchronously) { return(false); } return(this.HandleUpgrade(asyncResult)); }
private bool HandleUpgrade(IAsyncResult result) { this.connection = Microsoft.ServiceBus.Channels.ConnectionUpgradeHelper.EndInitiateUpgrade(result); this.channel.SetRemoteSecurity(this.upgradeInitiator); if (Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.SendPreambleAsyncResult.onUpgradeInitiatorClose == null) { Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.SendPreambleAsyncResult.onUpgradeInitiatorClose = Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ThunkAsyncCallback(new AsyncCallback(Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.SendPreambleAsyncResult.OnUpgradeInitiatorClose)); } Type type = this.upgradeInitiator.GetType(); StreamUpgradeInitiator streamUpgradeInitiator = this.upgradeInitiator; object[] objArray = new object[] { this.timeoutHelper.RemainingTime(), Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.SendPreambleAsyncResult.onUpgradeInitiatorClose, this }; IAsyncResult asyncResult = InvokeHelper.InvokeInstanceMethod(type, streamUpgradeInitiator, "BeginClose", objArray) as IAsyncResult; if (!asyncResult.CompletedSynchronously) { return(false); } return(this.HandleInitiatorClose(asyncResult)); }
private bool HandleUpgrade(IAsyncResult result) { this.connection = Microsoft.ServiceBus.Channels.ConnectionUpgradeHelper.EndInitiateUpgrade(result); if (this.upgradeInitiator is StreamSecurityUpgradeInitiator) { this.remoteSecurity = ((StreamSecurityUpgradeInitiator)this.upgradeInitiator).GetRemoteSecurity(); } this.upgradeInitiator = null; if (Microsoft.ServiceBus.Channels.StreamedFramingRequestChannel.StreamedConnectionPoolHelper.SendPreambleAsyncResult.onWritePreambleEnd == null) { Microsoft.ServiceBus.Channels.StreamedFramingRequestChannel.StreamedConnectionPoolHelper.SendPreambleAsyncResult.onWritePreambleEnd = Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ThunkAsyncCallback(new AsyncCallback(Microsoft.ServiceBus.Channels.StreamedFramingRequestChannel.StreamedConnectionPoolHelper.SendPreambleAsyncResult.OnWritePreambleEnd)); } IAsyncResult asyncResult = this.connection.BeginWrite(Microsoft.ServiceBus.Channels.ClientSingletonEncoder.PreambleEndBytes, 0, (int)Microsoft.ServiceBus.Channels.ClientSingletonEncoder.PreambleEndBytes.Length, true, this.timeoutHelper.RemainingTime(), Microsoft.ServiceBus.Channels.StreamedFramingRequestChannel.StreamedConnectionPoolHelper.SendPreambleAsyncResult.onWritePreambleEnd, this); if (!asyncResult.CompletedSynchronously) { return(false); } this.connection.EndWrite(asyncResult); return(this.ReadPreambleAck()); }
private bool HandleInitiatorClose(IAsyncResult result) { Type type = this.upgradeInitiator.GetType(); StreamUpgradeInitiator streamUpgradeInitiator = this.upgradeInitiator; object[] objArray = new object[] { result }; InvokeHelper.InvokeInstanceMethod(type, streamUpgradeInitiator, "EndClose", objArray); this.upgradeInitiator = null; if (Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.SendPreambleAsyncResult.onWritePreambleEnd == null) { Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.SendPreambleAsyncResult.onWritePreambleEnd = Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ThunkAsyncCallback(new AsyncCallback(Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.SendPreambleAsyncResult.OnWritePreambleEnd)); } IAsyncResult asyncResult = this.connection.BeginWrite(Microsoft.ServiceBus.Channels.SessionEncoder.PreambleEndBytes, 0, (int)Microsoft.ServiceBus.Channels.SessionEncoder.PreambleEndBytes.Length, true, this.timeoutHelper.RemainingTime(), Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.SendPreambleAsyncResult.onWritePreambleEnd, this); if (!asyncResult.CompletedSynchronously) { return(false); } this.connection.EndWrite(asyncResult); return(this.ReadAck()); }
private bool HandleWritePreamble(IAsyncResult result) { this.connection.EndWrite(result); if (this.channel.upgrade == null) { return(this.ReadAck()); } this.upgradeInitiator = this.channel.upgrade.CreateUpgradeInitiator(this.channel.RemoteAddress, this.channel.Via); if (Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.SendPreambleAsyncResult.onUpgradeInitiatorOpen == null) { Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.SendPreambleAsyncResult.onUpgradeInitiatorOpen = Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ThunkAsyncCallback(new AsyncCallback(Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.SendPreambleAsyncResult.OnUpgradeInitiatorOpen)); } Type type = this.upgradeInitiator.GetType(); StreamUpgradeInitiator streamUpgradeInitiator = this.upgradeInitiator; object[] objArray = new object[] { this.timeoutHelper.RemainingTime(), Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.SendPreambleAsyncResult.onUpgradeInitiatorOpen, this }; IAsyncResult asyncResult = InvokeHelper.InvokeInstanceMethod(type, streamUpgradeInitiator, "BeginOpen", objArray) as IAsyncResult; if (!asyncResult.CompletedSynchronously) { return(false); } return(this.HandleInitiatorOpen(asyncResult)); }
public InitiateUpgradeAsyncResult(IDefaultCommunicationTimeouts timeouts, EndpointAddress remoteAddress, Microsoft.ServiceBus.Channels.IConnection connection, Microsoft.ServiceBus.Channels.ClientFramingDecoder decoder, StreamUpgradeInitiator upgradeInitiator, string contentType, Microsoft.ServiceBus.Common.TimeoutHelper timeoutHelper, AsyncCallback callback, object state) : base(callback, state) { this.defaultTimeouts = timeouts; this.decoder = decoder; this.upgradeInitiator = upgradeInitiator; this.contentType = contentType; this.timeoutHelper = timeoutHelper; this.connection = connection; this.remoteAddress = remoteAddress; if (this.Begin()) { base.Complete(true); } }
public static IAsyncResult BeginInitiateUpgrade(IDefaultCommunicationTimeouts timeouts, EndpointAddress remoteAddress, Microsoft.ServiceBus.Channels.IConnection connection, Microsoft.ServiceBus.Channels.ClientFramingDecoder decoder, StreamUpgradeInitiator upgradeInitiator, string contentType, Microsoft.ServiceBus.Common.TimeoutHelper timeoutHelper, AsyncCallback callback, object state) { return(new Microsoft.ServiceBus.Channels.ConnectionUpgradeHelper.InitiateUpgradeAsyncResult(timeouts, remoteAddress, connection, decoder, upgradeInitiator, contentType, timeoutHelper, callback, state)); }