private bool HandleCloseInputSession(IAsyncResult result, bool isStillSynchronous) { Message message = this.channel.messageSource.EndReceive(result); if (message != null) { using (message) { Type type = typeof(ProtocolException); object[] objArray = new object[] { message }; ProtocolException protocolException = (ProtocolException)InvokeHelper.InvokeStaticMethod(type, "ReceiveShutdownReturnedNonNull", objArray); throw TraceUtility.ThrowHelperError(protocolException, message); } } this.channel.OnInputSessionClosed(); return(this.ScheduleCompleteClose(isStillSynchronous)); }
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 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 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()); }
protected override void OnClose(TimeSpan timeout) { TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); this.CloseOutputSession(timeoutHelper.RemainingTime()); if (!this.isInputSessionClosed) { Message message = this.messageSource.Receive(timeoutHelper.RemainingTime()); if (message != null) { using (message) { Type type = typeof(ProtocolException); object[] objArray = new object[] { message }; ProtocolException protocolException = (ProtocolException)InvokeHelper.InvokeStaticMethod(type, "ReceiveShutdownReturnedNonNull", objArray); throw TraceUtility.ThrowHelperError(protocolException, message); } } this.OnInputSessionClosed(); } this.CompleteClose(timeoutHelper.RemainingTime()); }
protected TransportOutputChannel(ChannelManagerBase channelManager, EndpointAddress to, Uri via, bool manualAddressing, System.ServiceModel.Channels.MessageVersion messageVersion) : base(channelManager) { this.manualAddressing = manualAddressing; this.messageVersion = messageVersion; this.to = to; this.via = via; if (!manualAddressing && to != null) { if (to.IsAnonymous) { this.toUri = (Uri)InvokeHelper.InvokeInstanceGet(typeof(AddressingVersion), this.messageVersion.Addressing, "AnonymousUri"); } else if (!to.IsNone) { this.toUri = to.Uri; } else { this.toUri = (Uri)InvokeHelper.InvokeInstanceGet(typeof(AddressingVersion), this.messageVersion.Addressing, "NoneUri"); } this.anyHeadersToAdd = to.Headers.Count > 0; } }
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)); }
protected FramingDuplexSessionChannel(Microsoft.ServiceBus.Channels.ConnectionOrientedTransportChannelListener channelListener, EndpointAddress localAddress, Uri localVia, bool exposeConnectionProperty) : this(channelListener, channelListener, localAddress, localVia, EndpointAddress2.AnonymousAddress, (Uri)InvokeHelper.InvokeInstanceGet(typeof(AddressingVersion), channelListener.MessageVersion.Addressing, "AnonymousUri"), exposeConnectionProperty) { this.duplexSession = Microsoft.ServiceBus.Channels.FramingDuplexSessionChannel.ConnectionDuplexSession.CreateSession(this, channelListener.Upgrade); }
protected FramingDuplexSessionChannel(ChannelManagerBase factory, Microsoft.ServiceBus.Channels.IConnectionOrientedTransportFactorySettings settings, EndpointAddress remoteAddresss, Uri via, bool exposeConnectionProperty) : this(factory, settings, EndpointAddress2.AnonymousAddress, (Uri)InvokeHelper.InvokeInstanceGet(typeof(AddressingVersion), settings.MessageVersion.Addressing, "AnonymousUri"), remoteAddresss, via, exposeConnectionProperty) { this.duplexSession = Microsoft.ServiceBus.Channels.FramingDuplexSessionChannel.ConnectionDuplexSession.CreateSession(this, settings.Upgrade); }
protected TransportChannelListener(TransportBindingElement bindingElement, BindingContext context, System.ServiceModel.Channels.MessageEncoderFactory defaultMessageEncoderFactory, HostNameComparisonMode hostNameComparisonMode) : base(context.Binding) { Microsoft.ServiceBus.Channels.HostNameComparisonModeHelper.Validate(hostNameComparisonMode); this.hostNameComparisonMode = hostNameComparisonMode; this.manualAddressing = bindingElement.ManualAddressing; this.maxBufferPoolSize = bindingElement.MaxBufferPoolSize; this.maxReceivedMessageSize = bindingElement.MaxReceivedMessageSize; Collection <MessageEncodingBindingElement> messageEncodingBindingElements = context.BindingParameters.FindAll <MessageEncodingBindingElement>(); if (messageEncodingBindingElements.Count > 1) { throw Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(Microsoft.ServiceBus.SR.GetString(Resources.MultipleMebesInParameters, new object[0]))); } if (messageEncodingBindingElements.Count != 1) { this.messageEncoderFactory = defaultMessageEncoderFactory; } else { this.messageEncoderFactory = messageEncodingBindingElements[0].CreateMessageEncoderFactory(); context.BindingParameters.Remove <MessageEncodingBindingElement>(); } if (this.messageEncoderFactory == null) { this.messageVersion = System.ServiceModel.Channels.MessageVersion.None; } else { this.messageVersion = this.messageEncoderFactory.MessageVersion; } ServiceSecurityAuditBehavior serviceSecurityAuditBehavior = context.BindingParameters.Find <ServiceSecurityAuditBehavior>(); if (serviceSecurityAuditBehavior == null) { this.auditBehavior = new ServiceSecurityAuditBehavior(); } else { this.auditBehavior = (ServiceSecurityAuditBehavior)InvokeHelper.InvokeInstanceMethod(typeof(ServiceSecurityAuditBehavior), serviceSecurityAuditBehavior, "Clone", new object[0]); } if (context.ListenUriMode == ListenUriMode.Unique && context.ListenUriBaseAddress == null) { UriBuilder uriBuilder = new UriBuilder(this.Scheme, Microsoft.ServiceBus.Channels.DnsCache.MachineName) { Path = this.GeneratedAddressPrefix }; context.ListenUriBaseAddress = uriBuilder.Uri; } Microsoft.ServiceBus.Channels.UriSchemeKeyedCollection.ValidateBaseAddress(context.ListenUriBaseAddress, "baseAddress"); if (context.ListenUriBaseAddress.Scheme != this.Scheme && !context.ListenUriBaseAddress.Scheme.Equals("sbwss") && string.Compare(context.ListenUriBaseAddress.Scheme, this.Scheme, StringComparison.OrdinalIgnoreCase) != 0) { ExceptionUtility exceptionUtility = Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility; string invalidUriScheme = Resources.InvalidUriScheme; object[] scheme = new object[] { context.ListenUriBaseAddress.Scheme, this.Scheme }; throw exceptionUtility.ThrowHelperArgument("context.ListenUriBaseAddress", Microsoft.ServiceBus.SR.GetString(invalidUriScheme, scheme)); } Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.DebugAssert(context.ListenUriRelativeAddress != null, ""); if (context.ListenUriMode != ListenUriMode.Explicit) { string listenUriRelativeAddress = context.ListenUriRelativeAddress; if (listenUriRelativeAddress.Length > 0 && !listenUriRelativeAddress.EndsWith("/", StringComparison.Ordinal)) { listenUriRelativeAddress = string.Concat(listenUriRelativeAddress, "/"); } System.Uri listenUriBaseAddress = context.ListenUriBaseAddress; Guid guid = Guid.NewGuid(); this.SetUri(listenUriBaseAddress, string.Concat(listenUriRelativeAddress, guid.ToString())); } else { this.SetUri(context.ListenUriBaseAddress, context.ListenUriRelativeAddress); } this.transportManagerContainer = new Microsoft.ServiceBus.Channels.TransportManagerContainer(this); }