Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Activation / HostedNamedPipeTransportManager.cs / 1 / HostedNamedPipeTransportManager.cs
//---------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------------------- namespace System.ServiceModel.Activation { using System.Collections.Generic; using System.Diagnostics; using System.ServiceModel; using System.ServiceModel.Channels; using System.ServiceModel.Diagnostics; class HostedNamedPipeTransportManager : NamedPipeTransportManager { bool settingsApplied; OnViaDelegate onViaCallback; SharedConnectionListener listener; ConnectionDemuxer connectionDemuxer; int queueId; Guid token; OnDuplicatedViaDelegate onDuplicatedViaCallback; bool demuxerCreated; public HostedNamedPipeTransportManager(BaseUriWithWildcard baseAddress) : base(baseAddress.BaseAddress) { this.HostNameComparisonMode = baseAddress.HostNameComparisonMode; this.onViaCallback = new OnViaDelegate(OnVia); this.onDuplicatedViaCallback = new OnDuplicatedViaDelegate(OnDuplicatedVia); } protected override bool IsCompatible(NamedPipeChannelListener channelListener) { if (channelListener.HostedVirtualPath == null) { return false; } return base.IsCompatible(channelListener); } internal void Start(int queueId, Guid token, MessageReceivedCallback messageReceivedCallback) { SetMessageReceivedCallback(messageReceivedCallback); OnOpenInternal(queueId, token); } internal override void OnOpen() { // This is intentionally empty. } internal void Stop() { lock (ThisLock) { if (listener != null) { listener.Stop(); // The listener will be closed by the demuxer. listener = null; } if (connectionDemuxer != null) { connectionDemuxer.Dispose(); } demuxerCreated = false; settingsApplied = false; } } void CreateConnectionDemuxer() { IConnectionListener connectionListener = new BufferedConnectionListener(listener, MaxOutputDelay, ConnectionBufferSize); if (DiagnosticUtility.ShouldUseActivity) { connectionListener = new TracingConnectionListener(connectionListener, this.ListenUri); } connectionDemuxer = new ConnectionDemuxer(connectionListener, MaxPendingAccepts, MaxPendingConnections, ChannelInitializationTimeout, IdleTimeout, MaxPooledConnections, OnGetTransportFactorySettings, OnGetSingletonMessageHandler, OnHandleServerSessionPreamble, OnDemuxerError); connectionDemuxer.StartDemuxing(onViaCallback); } void OnOpenInternal(int queueId, Guid token) { lock (ThisLock) { this.queueId = queueId; this.token = token; BaseUriWithWildcard path = new BaseUriWithWildcard(this.ListenUri, this.HostNameComparisonMode); listener = new SharedConnectionListener(path, queueId, token, this.onDuplicatedViaCallback); } } internal override void OnClose() { Stop(); base.OnClose(); } void OnVia(Uri address) { Debug.Print("HostedNamedPipeTransportManager.OnVia() address: " + address + " calling EnsureServiceAvailable()"); ServiceHostingEnvironment.EnsureServiceAvailable(address.LocalPath); } protected override void OnSelecting(NamedPipeChannelListener channelListener) { if (settingsApplied) { return; } lock (ThisLock) { if (settingsApplied) { // Use the setting for the first one. return; } this.ApplyListenerSettings(channelListener); settingsApplied = true; } } // This method is called only for the first via of the current proxy. void OnDuplicatedVia(Uri via, out int connectionBufferSize) { OnVia(via); if (!demuxerCreated) { lock (ThisLock) { if (listener == null) { // The listener has been stopped. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationObjectAbortedException( SR.GetString(SR.Sharing_ListenerProxyStopped))); } if (!demuxerCreated) { CreateConnectionDemuxer(); demuxerCreated = true; } } } connectionBufferSize = this.ConnectionBufferSize; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SystemIPGlobalStatistics.cs
- ToolStripLocationCancelEventArgs.cs
- CapabilitiesState.cs
- XmlTextWriter.cs
- Context.cs
- PolicyException.cs
- Sql8ExpressionRewriter.cs
- MetadataCache.cs
- _ContextAwareResult.cs
- ToolStripDropDownButton.cs
- AvTrace.cs
- RequiredFieldValidator.cs
- DataGridViewTopLeftHeaderCell.cs
- MergeExecutor.cs
- PreProcessor.cs
- EntitySqlException.cs
- ToolStripContentPanelDesigner.cs
- SafeSecurityHandles.cs
- SqlMethodTransformer.cs
- _ChunkParse.cs
- TypeConverterValueSerializer.cs
- LocalizableResourceBuilder.cs
- AnnotationHelper.cs
- MetadataCollection.cs
- TransformValueSerializer.cs
- HGlobalSafeHandle.cs
- Rfc2898DeriveBytes.cs
- NavigationService.cs
- DataGridViewColumnCollectionDialog.cs
- EncryptedData.cs
- PropertyChangingEventArgs.cs
- Facet.cs
- FixedSOMPageElement.cs
- DataGridColumnHeader.cs
- TextBox.cs
- ResolveNameEventArgs.cs
- DataGridViewComboBoxCell.cs
- ResourceIDHelper.cs
- SizeConverter.cs
- NavigationProgressEventArgs.cs
- MsmqMessageSerializationFormat.cs
- ChangeBlockUndoRecord.cs
- PassportAuthenticationModule.cs
- CTreeGenerator.cs
- RenderContext.cs
- SecurityAlgorithmSuiteConverter.cs
- DivideByZeroException.cs
- HostedElements.cs
- PointAnimationUsingKeyFrames.cs
- IndexOutOfRangeException.cs
- StringConverter.cs
- RoutedCommand.cs
- ClientRoleProvider.cs
- TaiwanLunisolarCalendar.cs
- NumberFormatter.cs
- Image.cs
- TrackingDataItemValue.cs
- AttributeEmitter.cs
- ToolStripTextBox.cs
- NativeWrapper.cs
- SrgsNameValueTag.cs
- CodeIdentifier.cs
- QueryStatement.cs
- StateDesigner.Layouts.cs
- XmlReflectionImporter.cs
- Monitor.cs
- _ContextAwareResult.cs
- BinaryMethodMessage.cs
- BatchServiceHost.cs
- EntityParameterCollection.cs
- ResXBuildProvider.cs
- SymmetricKey.cs
- UriTemplateClientFormatter.cs
- QilGeneratorEnv.cs
- TdsRecordBufferSetter.cs
- DbFunctionCommandTree.cs
- Substitution.cs
- SoapAttributeAttribute.cs
- LinkConverter.cs
- SiteMapDataSource.cs
- CharAnimationBase.cs
- ThaiBuddhistCalendar.cs
- UIPropertyMetadata.cs
- CodeTypeMemberCollection.cs
- ExpanderAutomationPeer.cs
- DashStyle.cs
- StdValidatorsAndConverters.cs
- TextBoxRenderer.cs
- Wizard.cs
- Expr.cs
- InputLanguageSource.cs
- _ConnectionGroup.cs
- SafeLocalMemHandle.cs
- Comparer.cs
- WebPartAddingEventArgs.cs
- SqlUtil.cs
- IgnorePropertiesAttribute.cs
- Normalization.cs
- SQLGuid.cs
- SRef.cs