Code:
/ 4.0 / 4.0 / 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. //---------------------------------------------------------------------------- // 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; Action onViaCallback; 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
- TaskFileService.cs
- GrammarBuilder.cs
- securitycriticaldataClass.cs
- SerializerWriterEventHandlers.cs
- ValidationUtility.cs
- DbExpressionVisitor_TResultType.cs
- BasicExpandProvider.cs
- CodeSnippetStatement.cs
- TextEditorSelection.cs
- AxDesigner.cs
- CompositeActivityTypeDescriptor.cs
- InternalSafeNativeMethods.cs
- TableHeaderCell.cs
- TypeSource.cs
- OleDbStruct.cs
- FileDialog_Vista_Interop.cs
- DelegatedStream.cs
- QilList.cs
- FtpWebRequest.cs
- CryptoApi.cs
- Matrix3DConverter.cs
- OracleTimeSpan.cs
- ObjectTag.cs
- DbSourceCommand.cs
- InplaceBitmapMetadataWriter.cs
- ResourceCategoryAttribute.cs
- XmlNamespaceDeclarationsAttribute.cs
- RoutingSection.cs
- TraceProvider.cs
- ExternalException.cs
- SrgsSubset.cs
- SHA1Cng.cs
- ProcessModuleCollection.cs
- Nodes.cs
- validationstate.cs
- OutputScopeManager.cs
- ScriptHandlerFactory.cs
- LoopExpression.cs
- WebSysDefaultValueAttribute.cs
- ConstNode.cs
- HttpVersion.cs
- UnauthorizedAccessException.cs
- AttributeCollection.cs
- ConnectionStringsExpressionBuilder.cs
- IsolatedStorage.cs
- ToolStripDropDownButton.cs
- datacache.cs
- InputProcessorProfiles.cs
- Parsers.cs
- Matrix3D.cs
- Menu.cs
- DateTimeOffset.cs
- MdiWindowListStrip.cs
- M3DUtil.cs
- HelpKeywordAttribute.cs
- Solver.cs
- LifetimeServices.cs
- MouseActionValueSerializer.cs
- WhitespaceRuleReader.cs
- TabControlCancelEvent.cs
- PolyBezierSegmentFigureLogic.cs
- ScrollViewerAutomationPeer.cs
- XmlHierarchicalEnumerable.cs
- XmlSerializer.cs
- IERequestCache.cs
- SqlProfileProvider.cs
- PrintDialog.cs
- HttpRawResponse.cs
- HtmlTextArea.cs
- DrawingState.cs
- RenderOptions.cs
- CompletionProxy.cs
- Visitors.cs
- EdmMember.cs
- X509RawDataKeyIdentifierClause.cs
- SemanticKeyElement.cs
- ObjectItemCollection.cs
- ResourcePart.cs
- EditorAttributeInfo.cs
- CompensateDesigner.cs
- FixedSOMGroup.cs
- IncomingWebRequestContext.cs
- XmlSchemaInfo.cs
- SecurityElementBase.cs
- ControlBindingsConverter.cs
- SystemBrushes.cs
- UnaryNode.cs
- GridView.cs
- ScaleTransform3D.cs
- AgileSafeNativeMemoryHandle.cs
- ValueTypeFixupInfo.cs
- BaseParser.cs
- TypeForwardedToAttribute.cs
- CompositeTypefaceMetrics.cs
- OperatingSystemVersionCheck.cs
- HotSpot.cs
- XslTransform.cs
- XmlSchemaElement.cs
- BitmapMetadataBlob.cs
- DbSourceParameterCollection.cs