Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / ConnectionOrientedTransportManager.cs / 1 / ConnectionOrientedTransportManager.cs
//----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//---------------------------------------------------------------------------
namespace System.ServiceModel.Channels
{
using System;
using System.ServiceModel.Activation;
using System.ServiceModel;
using System.Net;
using System.Net.Sockets;
using System.Collections.Generic;
abstract class ConnectionOrientedTransportManager : TransportManager
where TChannelListener : ConnectionOrientedTransportChannelListener
{
UriPrefixTable addressTable;
int connectionBufferSize;
TimeSpan channelInitializationTimeout;
int maxPendingConnections;
TimeSpan maxOutputDelay;
int maxPendingAccepts;
TimeSpan idleTimeout;
int maxPooledConnections;
MessageReceivedCallback messageReceivedCallback;
protected ConnectionOrientedTransportManager()
{
this.addressTable = new UriPrefixTable();
}
UriPrefixTable AddressTable
{
get { return addressTable; }
}
protected TimeSpan ChannelInitializationTimeout
{
get
{
return channelInitializationTimeout;
}
}
internal void ApplyListenerSettings(IConnectionOrientedListenerSettings listenerSettings)
{
this.connectionBufferSize = listenerSettings.ConnectionBufferSize;
this.channelInitializationTimeout = listenerSettings.ChannelInitializationTimeout;
this.maxPendingConnections = listenerSettings.MaxPendingConnections;
this.maxOutputDelay = listenerSettings.MaxOutputDelay;
this.maxPendingAccepts = listenerSettings.MaxPendingAccepts;
this.idleTimeout = listenerSettings.IdleTimeout;
this.maxPooledConnections = listenerSettings.MaxPooledConnections;
}
internal int ConnectionBufferSize
{
get
{
return this.connectionBufferSize;
}
}
internal int MaxPendingConnections
{
get
{
return this.maxPendingConnections;
}
}
internal TimeSpan MaxOutputDelay
{
get
{
return maxOutputDelay;
}
}
internal int MaxPendingAccepts
{
get
{
return this.maxPendingAccepts;
}
}
internal TimeSpan IdleTimeout
{
get { return this.idleTimeout; }
}
internal int MaxPooledConnections
{
get { return this.maxPooledConnections; }
}
internal bool IsCompatible(ConnectionOrientedTransportChannelListener channelListener)
{
if (channelListener.InheritBaseAddressSettings)
return true;
return (
(this.ChannelInitializationTimeout == channelListener.ChannelInitializationTimeout) &&
(this.ConnectionBufferSize == channelListener.ConnectionBufferSize) &&
(this.MaxPendingConnections == channelListener.MaxPendingConnections) &&
(this.MaxOutputDelay == channelListener.MaxOutputDelay) &&
(this.MaxPendingAccepts == channelListener.MaxPendingAccepts) &&
(this.idleTimeout == channelListener.IdleTimeout) &&
(this.maxPooledConnections == channelListener.MaxPooledConnections)
);
}
TChannelListener GetChannelListener(Uri via)
{
TChannelListener channelListener = null;
if (AddressTable.TryLookupUri(via, HostNameComparisonMode.StrongWildcard, out channelListener))
{
return channelListener;
}
if (AddressTable.TryLookupUri(via, HostNameComparisonMode.Exact, out channelListener))
{
return channelListener;
}
AddressTable.TryLookupUri(via, HostNameComparisonMode.WeakWildcard, out channelListener);
return channelListener;
}
internal void OnDemuxerError(Exception exception)
{
lock (ThisLock)
{
this.Fault(this.AddressTable, exception);
}
}
internal ISingletonChannelListener OnGetSingletonMessageHandler(ServerSingletonPreambleConnectionReader serverSingletonPreambleReader)
{
Uri via = serverSingletonPreambleReader.Via;
TChannelListener channelListener = GetChannelListener(via);
if (channelListener != null)
{
if (channelListener is IChannelListener)
{
channelListener.RaiseMessageReceived();
return (ISingletonChannelListener)channelListener;
}
else
{
serverSingletonPreambleReader.SendFault(FramingEncodingString.UnsupportedModeFault);
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
new ProtocolException(SR.GetString(SR.FramingModeNotSupported, FramingMode.Singleton)));
}
}
else
{
serverSingletonPreambleReader.SendFault(FramingEncodingString.EndpointNotFoundFault);
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
new EndpointNotFoundException(SR.GetString(SR.EndpointNotFound, via)));
}
}
internal void OnHandleServerSessionPreamble(ServerSessionPreambleConnectionReader serverSessionPreambleReader,
ConnectionDemuxer connectionDemuxer)
{
Uri via = serverSessionPreambleReader.Via;
TChannelListener channelListener = GetChannelListener(via);
if (channelListener != null)
{
ISessionPreambleHandler sessionPreambleHandler = channelListener as ISessionPreambleHandler;
if (sessionPreambleHandler != null && channelListener is IChannelListener)
{
sessionPreambleHandler.HandleServerSessionPreamble(serverSessionPreambleReader, connectionDemuxer);
}
else
{
serverSessionPreambleReader.SendFault(FramingEncodingString.UnsupportedModeFault);
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
new ProtocolException(SR.GetString(SR.FramingModeNotSupported, FramingMode.Duplex)));
}
}
else
{
serverSessionPreambleReader.SendFault(FramingEncodingString.EndpointNotFoundFault);
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new EndpointNotFoundException(SR.GetString(SR.DuplexSessionListenerNotFound, via.ToString())));
}
}
internal IConnectionOrientedTransportFactorySettings OnGetTransportFactorySettings(Uri via)
{
return GetChannelListener(via);
}
internal override void Register(TransportChannelListener channelListener)
{
AddressTable.RegisterUri(channelListener.Uri, channelListener.HostNameComparisonModeInternal,
(TChannelListener)channelListener);
channelListener.SetMessageReceivedCallback(new MessageReceivedCallback(OnMessageReceived));
}
internal override void Unregister(TransportChannelListener channelListener)
{
EnsureRegistered(AddressTable, (TChannelListener)channelListener, channelListener.HostNameComparisonModeInternal);
AddressTable.UnregisterUri(channelListener.Uri, channelListener.HostNameComparisonModeInternal);
channelListener.SetMessageReceivedCallback(null);
}
internal void SetMessageReceivedCallback(MessageReceivedCallback messageReceivedCallback)
{
this.messageReceivedCallback = messageReceivedCallback;
}
void OnMessageReceived()
{
if (messageReceivedCallback != null)
{
messageReceivedCallback();
}
}
}
}
// 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
- XmlSchemaSimpleContentExtension.cs
- DiscoveryDocument.cs
- UpdatePanelControlTrigger.cs
- IPHostEntry.cs
- SectionInformation.cs
- FragmentQueryKB.cs
- COSERVERINFO.cs
- DecimalConverter.cs
- OrderedDictionary.cs
- Axis.cs
- ColorTransform.cs
- BinaryMethodMessage.cs
- TextBox.cs
- StorageFunctionMapping.cs
- DateTimeValueSerializer.cs
- Win32PrintDialog.cs
- XmlImplementation.cs
- CodeLinePragma.cs
- CompilerState.cs
- CannotUnloadAppDomainException.cs
- InputLanguageCollection.cs
- CompilerGeneratedAttribute.cs
- StylusPointPropertyId.cs
- WebPartChrome.cs
- WeakEventTable.cs
- StructuredProperty.cs
- ListViewUpdatedEventArgs.cs
- ObjectDataSourceMethodEventArgs.cs
- EncoderParameters.cs
- XsdDuration.cs
- XmlSchemaAttributeGroup.cs
- BoundPropertyEntry.cs
- CommandManager.cs
- IndexerNameAttribute.cs
- HMAC.cs
- FrugalList.cs
- GridViewCellAutomationPeer.cs
- DPCustomTypeDescriptor.cs
- AddressAccessDeniedException.cs
- Number.cs
- SoapSchemaImporter.cs
- activationcontext.cs
- WebControlsSection.cs
- SyndicationSerializer.cs
- TdsRecordBufferSetter.cs
- Debugger.cs
- HttpApplicationStateWrapper.cs
- CompressStream.cs
- ScriptingWebServicesSectionGroup.cs
- AccessibilityHelperForXpWin2k3.cs
- ColorConverter.cs
- TextCompositionManager.cs
- XmlReader.cs
- AsyncSerializedWorker.cs
- EventLogger.cs
- TypeDescriptionProvider.cs
- WFItemsToSpacerVisibility.cs
- RelationshipManager.cs
- OptimizedTemplateContent.cs
- DataGridHeaderBorder.cs
- XmlTextReaderImplHelpers.cs
- KeyProperty.cs
- GrammarBuilder.cs
- BamlTreeNode.cs
- HttpCapabilitiesEvaluator.cs
- SQLDecimal.cs
- RightsManagementEncryptionTransform.cs
- CompilerErrorCollection.cs
- IIS7WorkerRequest.cs
- DbParameterCollectionHelper.cs
- InstanceData.cs
- SqlDataRecord.cs
- TextWriter.cs
- OdbcFactory.cs
- KeyValueConfigurationCollection.cs
- ScriptManagerProxy.cs
- uribuilder.cs
- TransactionChannelListener.cs
- WebPartTransformerAttribute.cs
- CommandCollectionEditor.cs
- GenerateHelper.cs
- Graphics.cs
- SapiInterop.cs
- AsymmetricAlgorithm.cs
- SessionEndedEventArgs.cs
- HierarchicalDataBoundControl.cs
- IPGlobalProperties.cs
- X509Certificate.cs
- LinkButton.cs
- TraceContext.cs
- ScrollItemProviderWrapper.cs
- TextTreeUndo.cs
- SerialPinChanges.cs
- NonBatchDirectoryCompiler.cs
- xamlnodes.cs
- StylusSystemGestureEventArgs.cs
- XPathNavigatorKeyComparer.cs
- Int16Animation.cs
- WindowsListViewItem.cs
- Converter.cs