Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / SharedTcpTransportManager.cs / 1 / SharedTcpTransportManager.cs
//---------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------------------- namespace System.ServiceModel.Channels { using System.ServiceModel.Activation; using System.Collections.Generic; using System.Diagnostics; using System.ServiceModel; using System.Threading; using System.ServiceModel.Diagnostics; class SharedTcpTransportManager : TcpTransportManager, ITransportManagerRegistration { SharedConnectionListener listener; ConnectionDemuxer connectionDemuxer; HostNameComparisonMode hostNameComparisonMode; Uri listenUri; int queueId; Guid token; OnDuplicatedViaDelegate onDuplicatedViaCallback; bool demuxerCreated; public SharedTcpTransportManager(Uri listenUri, TcpChannelListener channelListener) { this.HostNameComparisonMode = channelListener.HostNameComparisonMode; this.listenUri = listenUri; // For port sharing, we apply all of the settings from channel listener to the transport manager. this.ApplyListenerSettings(channelListener); } protected SharedTcpTransportManager(Uri listenUri) { this.listenUri = listenUri; } protected override bool IsCompatible(TcpChannelListener channelListener) { if (channelListener.HostedVirtualPath == null && !channelListener.PortSharingEnabled) { return false; } return base.IsCompatible(channelListener); } public HostNameComparisonMode HostNameComparisonMode { get { return this.hostNameComparisonMode; } set { HostNameComparisonModeHelper.Validate(value); lock (base.ThisLock) { ThrowIfOpen(); this.hostNameComparisonMode = value; } } } public Uri ListenUri { get { return this.listenUri; } } internal override void OnOpen() { OnOpenInternal(0, Guid.Empty); } protected virtual OnViaDelegate GetOnViaCallback() { return null; } // This method is called only for the first via of the current proxy. void OnDuplicatedVia(Uri via, out int connectionBufferSize) { OnViaDelegate onVia = GetOnViaCallback(); if (onVia != null) { 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; } 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(this.GetOnViaCallback()); } internal void OnOpenInternal(int queueId, Guid token) { lock (ThisLock) { this.queueId = queueId; this.token = token; BaseUriWithWildcard path = new BaseUriWithWildcard(this.ListenUri, this.HostNameComparisonMode); if (this.onDuplicatedViaCallback == null) { this.onDuplicatedViaCallback = new OnDuplicatedViaDelegate(OnDuplicatedVia); } listener = new SharedConnectionListener(path, queueId, token, this.onDuplicatedViaCallback); // Delay the creation of the demuxer on the first request. } } protected void CleanUp() { lock (ThisLock) { if (listener != null) { listener.Stop(); // The listener will be closed by the demuxer. listener = null; } if (connectionDemuxer != null) { connectionDemuxer.Dispose(); } demuxerCreated = false; } } internal override void OnClose() { CleanUp(); TcpChannelListener.StaticTransportManagerTable.UnregisterUri(this.ListenUri, this.HostNameComparisonMode); } protected virtual void OnSelecting(TcpChannelListener channelListener) { } IListITransportManagerRegistration.Select(TransportChannelListener channelListener) { if (!channelListener.IsScopeIdCompatible(this.hostNameComparisonMode, this.listenUri)) { return null; } OnSelecting((TcpChannelListener)channelListener); IList result = null; if (this.IsCompatible((TcpChannelListener)channelListener)) { result = new List (); result.Add(this); } return result; } } } // 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
- HtmlString.cs
- IndexedWhereQueryOperator.cs
- XhtmlConformanceSection.cs
- TypedLocationWrapper.cs
- HttpErrorTraceRecord.cs
- PenLineJoinValidation.cs
- XmlExpressionDumper.cs
- ProjectionAnalyzer.cs
- FontSource.cs
- PathSegmentCollection.cs
- SiteMapDataSourceView.cs
- SqlDataSourceView.cs
- StringReader.cs
- NativeMethodsCLR.cs
- MetadataArtifactLoaderCompositeResource.cs
- OutputCacheSettingsSection.cs
- Size3DConverter.cs
- ServiceBusyException.cs
- PolicyException.cs
- CollectionType.cs
- HttpResponseWrapper.cs
- HttpBufferlessInputStream.cs
- Latin1Encoding.cs
- EtwTrace.cs
- CacheRequest.cs
- HandlerBase.cs
- ScaleTransform3D.cs
- PageContentCollection.cs
- HeaderedItemsControl.cs
- DecimalSumAggregationOperator.cs
- StaticDataManager.cs
- RegistrationServices.cs
- LicenseProviderAttribute.cs
- FileSystemWatcher.cs
- PrePrepareMethodAttribute.cs
- PackageDigitalSignatureManager.cs
- ApplicationFileCodeDomTreeGenerator.cs
- DiscriminatorMap.cs
- ManagedIStream.cs
- GroupBox.cs
- IQueryable.cs
- WeakReferenceList.cs
- Keyboard.cs
- WorkflowTransactionOptions.cs
- HttpListenerTimeoutManager.cs
- EventOpcode.cs
- ReversePositionQuery.cs
- ArraySortHelper.cs
- SqlGatherProducedAliases.cs
- InvokeGenerator.cs
- LogStream.cs
- DbXmlEnabledProviderManifest.cs
- WebPartCloseVerb.cs
- OleDbRowUpdatingEvent.cs
- XmlSchemaObject.cs
- SkinBuilder.cs
- HtmlInputHidden.cs
- EntityModelBuildProvider.cs
- CatalogZoneBase.cs
- TransactionState.cs
- WhitespaceRule.cs
- SetIndexBinder.cs
- Point3D.cs
- MatrixKeyFrameCollection.cs
- Psha1DerivedKeyGenerator.cs
- ReversePositionQuery.cs
- DataGridViewCellFormattingEventArgs.cs
- LeafCellTreeNode.cs
- DetailsViewPagerRow.cs
- Int64AnimationUsingKeyFrames.cs
- contentDescriptor.cs
- PropertyTabChangedEvent.cs
- UiaCoreTypesApi.cs
- DataGridViewSelectedCellCollection.cs
- RootBuilder.cs
- MarshalByValueComponent.cs
- CapabilitiesSection.cs
- FullTextState.cs
- CommandEventArgs.cs
- SharedDp.cs
- StreamGeometry.cs
- XamlVector3DCollectionSerializer.cs
- SqlCharStream.cs
- ClientScriptItemCollection.cs
- WebMessageEncodingElement.cs
- CellRelation.cs
- ToolStripItemClickedEventArgs.cs
- DocumentViewerConstants.cs
- XmlSerializerVersionAttribute.cs
- NTAccount.cs
- SafeNativeMethods.cs
- EventLogReader.cs
- EntryPointNotFoundException.cs
- FixedTextSelectionProcessor.cs
- FontWeights.cs
- EditingCoordinator.cs
- PhonemeEventArgs.cs
- BinaryObjectReader.cs
- CompilationSection.cs
- shaperfactoryquerycacheentry.cs