Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / System.ServiceModel.Activation / System / ServiceModel / Activation / HostedNamedPipeTransportManager.cs / 1305376 / 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; ActiononViaCallback; SharedConnectionListener listener; ConnectionDemuxer connectionDemuxer; int queueId; Guid token; Func onDuplicatedViaCallback; bool demuxerCreated; public HostedNamedPipeTransportManager(BaseUriWithWildcard baseAddress) : base(baseAddress.BaseAddress) { this.HostNameComparisonMode = baseAddress.HostNameComparisonMode; this.onViaCallback = new Action (OnVia); this.onDuplicatedViaCallback = new Func (OnDuplicatedVia); } protected override bool IsCompatible(NamedPipeChannelListener channelListener) { if (channelListener.HostedVirtualPath == null) { return false; } return base.IsCompatible(channelListener); } internal void Start(int queueId, Guid token, Action messageReceivedCallback) { SetMessageReceivedCallback(messageReceivedCallback); OnOpenInternal(queueId, token); } internal override void OnOpen() { // This is intentionally empty. } internal override void OnAbort() { } internal void Stop(TimeSpan timeout) { Cleanup(false, timeout); } void Cleanup(bool aborting, TimeSpan timeout) { lock (ThisLock) { if (listener != null) { if (!aborting) { listener.Stop(timeout); } else { listener.Abort(); } // 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(TimeSpan timeout) { } 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. int OnDuplicatedVia(Uri via) { OnVia(via); if (!demuxerCreated) { lock (ThisLock) { if (listener == null) { // The listener has been stopped. throw FxTrace.Exception.AsError(new CommunicationObjectAbortedException(SR.PipeListenerProxyStopped)); } if (!demuxerCreated) { CreateConnectionDemuxer(); demuxerCreated = true; } } } return this.ConnectionBufferSize; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlBindingWorker.cs
- DataSourceListEditor.cs
- MimeWriter.cs
- DataKey.cs
- SmtpNtlmAuthenticationModule.cs
- BamlRecordHelper.cs
- CompoundFileDeflateTransform.cs
- ReflectionHelper.cs
- StateFinalizationActivity.cs
- Calendar.cs
- CompilerTypeWithParams.cs
- RegisteredArrayDeclaration.cs
- OperationInfoBase.cs
- XmlSchemaObjectTable.cs
- XPathNavigatorReader.cs
- BinaryReader.cs
- CompiledQuery.cs
- EdmPropertyAttribute.cs
- AdCreatedEventArgs.cs
- XmlSchemaSimpleTypeUnion.cs
- WeakHashtable.cs
- AnimationLayer.cs
- DataGridViewAutoSizeModeEventArgs.cs
- Zone.cs
- MetadataItemCollectionFactory.cs
- TreeNodeCollectionEditorDialog.cs
- WaitHandleCannotBeOpenedException.cs
- ParseHttpDate.cs
- CodeTypeReferenceCollection.cs
- FilteredSchemaElementLookUpTable.cs
- DomainUpDown.cs
- Delay.cs
- OrderPreservingPipeliningSpoolingTask.cs
- DataGridToolTip.cs
- SiteMapDataSource.cs
- SqlDependencyListener.cs
- DES.cs
- StringValueConverter.cs
- BuildProviderAppliesToAttribute.cs
- SystemKeyConverter.cs
- SystemInfo.cs
- FeatureSupport.cs
- HelpProvider.cs
- BulletedListEventArgs.cs
- XmlSerializerSection.cs
- InputLanguage.cs
- WebRequest.cs
- JsonUriDataContract.cs
- PreloadedPackages.cs
- AudioLevelUpdatedEventArgs.cs
- XPathPatternParser.cs
- FrameworkElement.cs
- BitmapEncoder.cs
- UInt16.cs
- SapiGrammar.cs
- XmlArrayItemAttributes.cs
- Rotation3D.cs
- FontFamilyValueSerializer.cs
- OleStrCAMarshaler.cs
- AssemblyInfo.cs
- NoResizeHandleGlyph.cs
- PeerNameResolver.cs
- RowToParametersTransformer.cs
- ColorAnimation.cs
- CrossAppDomainChannel.cs
- Int16.cs
- BinHexEncoder.cs
- HostedElements.cs
- StaticExtensionConverter.cs
- BitmapMetadataEnumerator.cs
- BitmapFrameDecode.cs
- UnionExpr.cs
- PersonalizationProviderCollection.cs
- TableParagraph.cs
- AttributeEmitter.cs
- DataGridViewSortCompareEventArgs.cs
- MetabaseSettingsIis7.cs
- XAMLParseException.cs
- Parameter.cs
- TypeElement.cs
- PropertyItem.cs
- EventWaitHandle.cs
- TextHidden.cs
- EventMappingSettings.cs
- IssuanceLicense.cs
- DockPanel.cs
- WebPartZoneCollection.cs
- DocumentScope.cs
- DataGridRow.cs
- DynamicQueryStringParameter.cs
- _Connection.cs
- TickBar.cs
- IgnoreSection.cs
- ListParagraph.cs
- X509Certificate2.cs
- WebPartManagerInternals.cs
- ModelTreeEnumerator.cs
- XmlUtilWriter.cs
- IList.cs
- Events.cs