private void SetBufferManager() { ITransportFactorySettings transportSettings = GetProperty <ITransportFactorySettings>(); if (transportSettings == null) { return; } BufferManager bufferManager = transportSettings.BufferManager; if (bufferManager == null) { return; } if (SessionMode && SessionClientSettings != null && SessionClientSettings.SessionProtocolFactory != null) { SessionClientSettings.SessionProtocolFactory.StreamBufferManager = bufferManager; } else { ThrowIfProtocolFactoryNotSet(); SecurityProtocolFactory.StreamBufferManager = bufferManager; } }
void SetBufferManager() { ITransportFactorySettings transportSettings = this.innerListener.GetProperty <ITransportFactorySettings>(); if (transportSettings == null) { return; } BufferManager bufferManager = transportSettings.BufferManager; if (bufferManager == null) { return; } if (this.securityProtocolFactory != null) { this.securityProtocolFactory.StreamBufferManager = bufferManager; } if (this.sessionMode && this.sessionSettings != null && this.sessionSettings.SessionProtocolFactory != null) { this.sessionSettings.SessionProtocolFactory.StreamBufferManager = bufferManager; } }
public ServerFramingDuplexSessionChannel(FramingConnection connection, ITransportFactorySettings settings, bool exposeConnectionProperty, IServiceProvider serviceProvider) : base(connection, settings, exposeConnectionProperty) { Connection = connection; _serviceProvider = serviceProvider; SetMessageSource(new ServerSessionConnectionMessageSource(connection)); }
public WebSocketTransportDuplexSessionChannel(HttpChannelFactory<IDuplexSessionChannel> channelFactory, EndpointAddress remoteAddresss, Uri via) : base(channelFactory, channelFactory, EndpointAddress.AnonymousAddress, channelFactory.MessageVersion.Addressing.AnonymousUri, remoteAddresss, via) { Fx.Assert(channelFactory.WebSocketSettings != null, "channelFactory.WebSocketTransportSettings should not be null."); _webSocketSettings = channelFactory.WebSocketSettings; _transferMode = channelFactory.TransferMode; _maxBufferSize = channelFactory.MaxBufferSize; _transportFactorySettings = channelFactory; }
public ServerFramingDuplexSessionChannel(FramingConnection connection, ITransportFactorySettings settings, bool exposeConnectionProperty, IServiceProvider serviceProvider) : base(connection, settings, exposeConnectionProperty) { Connection = connection; upgradeAcceptor = connection.StreamUpgradeAcceptor; _serviceProvider = serviceProvider; //if (upgradeAcceptor != null) //{ // this.channelBindingProvider = upgrade.GetProperty<IStreamUpgradeChannelBindingProvider>(); // this.upgradeAcceptor = upgrade.CreateUpgradeAcceptor(); //} }
protected TransportDuplexSessionChannel( ITransportFactorySettings settings, EndpointAddress localAddress, Uri localVia, EndpointAddress remoteAddress, Uri via) : base(settings, remoteAddress, via, settings.ManualAddressing, settings.MessageVersion) { LocalAddress = localAddress; LocalVia = localVia; BufferManager = settings.BufferManager; MessageEncoder = settings.MessageEncoderFactory.CreateSessionEncoder(); Session = new ConnectionDuplexSession(this); }
protected TransportDuplexSessionChannel( ChannelManagerBase manager, ITransportFactorySettings settings, EndpointAddress localAddress, Uri localVia, EndpointAddress remoteAddresss, Uri via) : base(manager, remoteAddresss, via, settings.ManualAddressing, settings.MessageVersion) { _localAddress = localAddress; _localVia = localVia; _bufferManager = settings.BufferManager; _sendLock = new SemaphoreSlim(1); _messageEncoder = settings.MessageEncoderFactory.CreateSessionEncoder(); this.Session = new ConnectionDuplexSession(this); }
protected TransportDuplexSessionChannel( ChannelManagerBase manager, ITransportFactorySettings settings, EndpointAddress localAddress, Uri localVia, EndpointAddress remoteAddress, Uri via) : base(manager, remoteAddress, via, settings.ManualAddressing, settings.MessageVersion) { LocalAddress = localAddress; _localVia = localVia; BufferManager = settings.BufferManager; SendLock = new SemaphoreSlim(1); MessageEncoder = settings.MessageEncoderFactory.CreateSessionEncoder(); Session = new ConnectionDuplexSession(this); }
protected TransportDuplexSessionChannel( ChannelManagerBase manager, ITransportFactorySettings settings, EndpointAddress localAddress, Uri localVia, EndpointAddress remoteAddresss, Uri via) : base(manager, remoteAddresss, via, settings.ManualAddressing, settings.MessageVersion) { this.localAddress = localAddress; this.localVia = localVia; this.bufferManager = settings.BufferManager; this.sendLock = new ThreadNeutralSemaphore(1); this.messageEncoder = settings.MessageEncoderFactory.CreateSessionEncoder(); this.Session = new ConnectionDuplexSession(this); }
private void SetBufferManager() { ITransportFactorySettings property = this.GetProperty <ITransportFactorySettings>(); if (property == null) { return; } BufferManager bufferManager = property.BufferManager; if (bufferManager == null) { return; } if (this.SessionMode && this.SessionClientSettings != null && this.SessionClientSettings.SessionProtocolFactory != null) { this.SessionClientSettings.SessionProtocolFactory.StreamBufferManager = bufferManager; } else { this.ThrowIfProtocolFactoryNotSet(); this.securityProtocolFactory.StreamBufferManager = bufferManager; } }
protected FramingDuplexSessionChannel(FramingConnection connection, ITransportFactorySettings settings, bool exposeConnectionProperty) : this(settings, new EndpointAddress(connection.ServiceDispatcher.BaseAddress), connection.Via, EndpointAddress.AnonymousAddress, connection.MessageEncoder.MessageVersion.Addressing.AnonymousUri, exposeConnectionProperty) { Session = FramingConnectionDuplexSession.CreateSession(this, connection.StreamUpgradeAcceptor); }
private FramingDuplexSessionChannel(ITransportFactorySettings settings, EndpointAddress localAddress, Uri localVia, EndpointAddress remoteAddress, Uri via, bool exposeConnectionProperty) : base(settings, localAddress, localVia, remoteAddress, via) { this.exposeConnectionProperty = exposeConnectionProperty; }
public IAsyncResult BeginSend(object registrant, Message message, Uri via, ITransportFactorySettings settings, TimeSpan timeout, AsyncCallback callback, object state, SecurityProtocol securityProtocol) { PeerFlooder localFlooder; int factoryMaxReceivedMessageSize; TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); MessageBuffer messageBuffer = null; Message securedMessage = null; ulong hopcount = PeerTransportConstants.MaxHopCount; PeerMessagePropagation propagateFlags = PeerMessagePropagation.LocalAndRemote; int messageSize = (int)-1; byte[] id; SendAsyncResult result = new SendAsyncResult(callback, state); AsyncCallback onFloodComplete = Fx.ThunkCallback(new AsyncCallback(result.OnFloodComplete)); try { lock (ThisLock) { ThrowIfNotOpen(); localFlooder = flooder; } // we know this will fit in an int because of our MaxReceivedMessageSize restrictions factoryMaxReceivedMessageSize = (int)Math.Min(maxReceivedMessageSize, settings.MaxReceivedMessageSize); Guid guid = ProcessOutgoingMessage(message, via); SecureOutgoingMessage(ref message, via, timeout, securityProtocol); if ((message is SecurityAppliedMessage)) { ArraySegment<byte> buffer = encoder.WriteMessage(message, int.MaxValue, bufferManager); securedMessage = encoder.ReadMessage(buffer, bufferManager); id = (message as SecurityAppliedMessage).PrimarySignatureValue; messageSize = (int)buffer.Count; } else { securedMessage = message; id = guid.ToByteArray(); } messageBuffer = securedMessage.CreateBufferedCopy(factoryMaxReceivedMessageSize); string contentType = settings.MessageEncoderFactory.Encoder.ContentType; if (this.messagePropagationFilter != null) { using (Message filterMessage = messageBuffer.CreateMessage()) { propagateFlags = ((IPeerNodeMessageHandling)this).DetermineMessagePropagation(filterMessage, PeerMessageOrigination.Local); } } if ((propagateFlags & PeerMessagePropagation.Remote) != PeerMessagePropagation.None) { if (hopcount == 0) propagateFlags &= ~PeerMessagePropagation.Remote; } // flood it out IAsyncResult ar = null; if ((propagateFlags & PeerMessagePropagation.Remote) != 0) { ar = localFlooder.BeginFloodEncodedMessage(id, messageBuffer, timeoutHelper.RemainingTime(), onFloodComplete, null); if (DiagnosticUtility.ShouldTraceVerbose) { TraceUtility.TraceEvent(TraceEventType.Verbose, TraceCode.PeerChannelMessageSent, SR.GetString(SR.TraceCodePeerChannelMessageSent), this, message); } } else { ar = new CompletedAsyncResult(onFloodComplete, null); } if (ar == null) { Fx.Assert("SendAsyncResult must have an Async Result for onFloodComplete"); } // queue up the pre-encoded message for local channels if ((propagateFlags & PeerMessagePropagation.Local) != 0) { using (Message msg = messageBuffer.CreateMessage()) { int i = msg.Headers.FindHeader(SecurityJan2004Strings.Security, SecurityJan2004Strings.Namespace); if (i >= 0) { msg.Headers.AddUnderstood(i); } using (MessageBuffer clientBuffer = msg.CreateBufferedCopy(factoryMaxReceivedMessageSize)) { DeliverMessageToClientChannels(registrant, clientBuffer, via, message.Headers.To, contentType, messageSize, -1, null); } } } result.OnLocalDispatchComplete(result); } finally { message.Close(); if (securedMessage != null) securedMessage.Close(); if (messageBuffer != null) messageBuffer.Close(); } return result; }
// internal message filtering internal void RegisterMessageFilter(object registrant, Uri via, PeerMessageFilter[] filters, ITransportFactorySettings settings, MessageAvailableCallback callback, SecurityProtocol securityProtocol) { MessageFilterRegistration registration = new MessageFilterRegistration(); registration.registrant = registrant; registration.via = via; registration.filters = filters; registration.settings = settings; registration.callback = callback; registration.securityProtocol = securityProtocol; lock (ThisLock) { messageFilters.Add(registrant, registration); RefCountedSecurityProtocol protocolWrapper = null; if (!this.uri2SecurityProtocol.TryGetValue(via, out protocolWrapper)) { protocolWrapper = new RefCountedSecurityProtocol(securityProtocol); this.uri2SecurityProtocol.Add(via, protocolWrapper); } else protocolWrapper.AddRef(); } }
public InputChannel(ITransportFactorySettings settings, EndpointAddress localAddress, IServiceProvider serviceProvider) : base(settings) { LocalAddress = localAddress; _serviceProvider = serviceProvider; }
public ConnectionOrientedTransportReplyChannel(ITransportFactorySettings settings, EndpointAddress localAddress, IServiceProvider serviceProvider) : base(settings, localAddress) { _serviceProvider = serviceProvider; }
public IAsyncResult BeginSend(object registrant, Message message, Uri via, ITransportFactorySettings settings, TimeSpan timeout, AsyncCallback callback, object state, SecurityProtocol securityProtocol) { TimeoutHelper helper = new TimeoutHelper(timeout); MessageBuffer encodedMessage = null; Message message2 = null; ulong maxValue = ulong.MaxValue; PeerMessagePropagation localAndRemote = PeerMessagePropagation.LocalAndRemote; int messageSize = -1; SendAsyncResult result = new SendAsyncResult(callback, state); AsyncCallback callback2 = Fx.ThunkCallback(new AsyncCallback(result.OnFloodComplete)); try { PeerFlooder flooder; byte[] primarySignatureValue; lock (this.ThisLock) { this.ThrowIfNotOpen(); flooder = this.flooder; } int maxBufferSize = (int) Math.Min(this.maxReceivedMessageSize, settings.MaxReceivedMessageSize); Guid guid = this.ProcessOutgoingMessage(message, via); this.SecureOutgoingMessage(ref message, via, timeout, securityProtocol); if (message is SecurityAppliedMessage) { ArraySegment<byte> buffer = this.encoder.WriteMessage(message, 0x7fffffff, this.bufferManager); message2 = this.encoder.ReadMessage(buffer, this.bufferManager); primarySignatureValue = (message as SecurityAppliedMessage).PrimarySignatureValue; messageSize = buffer.Count; } else { message2 = message; primarySignatureValue = guid.ToByteArray(); } encodedMessage = message2.CreateBufferedCopy(maxBufferSize); string contentType = settings.MessageEncoderFactory.Encoder.ContentType; if (this.messagePropagationFilter != null) { using (Message message3 = encodedMessage.CreateMessage()) { localAndRemote = ((IPeerNodeMessageHandling) this).DetermineMessagePropagation(message3, PeerMessageOrigination.Local); } } if (((localAndRemote & PeerMessagePropagation.Remote) != PeerMessagePropagation.None) && (maxValue == 0L)) { localAndRemote &= ~PeerMessagePropagation.Remote; } IAsyncResult result2 = null; if ((localAndRemote & PeerMessagePropagation.Remote) != PeerMessagePropagation.None) { result2 = flooder.BeginFloodEncodedMessage(primarySignatureValue, encodedMessage, helper.RemainingTime(), callback2, null); if (System.ServiceModel.DiagnosticUtility.ShouldTraceVerbose) { TraceUtility.TraceEvent(TraceEventType.Verbose, 0x4003e, System.ServiceModel.SR.GetString("TraceCodePeerChannelMessageSent"), this, message); } } else { result2 = new CompletedAsyncResult(callback2, null); } if ((localAndRemote & PeerMessagePropagation.Local) != PeerMessagePropagation.None) { using (Message message4 = encodedMessage.CreateMessage()) { int i = message4.Headers.FindHeader("Security", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"); if (i >= 0) { message4.Headers.AddUnderstood(i); } using (MessageBuffer buffer3 = message4.CreateBufferedCopy(maxBufferSize)) { this.DeliverMessageToClientChannels(registrant, buffer3, via, message.Headers.To, contentType, messageSize, -1, null); } } } result.OnLocalDispatchComplete(result); } finally { message.Close(); if (message2 != null) { message2.Close(); } if (encodedMessage != null) { encodedMessage.Close(); } } return result; }
internal void RegisterMessageFilter(object registrant, Uri via, PeerMessageFilter[] filters, ITransportFactorySettings settings, MessageAvailableCallback callback, SecurityProtocol securityProtocol) { MessageFilterRegistration registration = new MessageFilterRegistration { registrant = registrant, via = via, filters = filters, settings = settings, callback = callback, securityProtocol = securityProtocol }; lock (this.ThisLock) { this.messageFilters.Add(registrant, registration); RefCountedSecurityProtocol protocol = null; if (!this.uri2SecurityProtocol.TryGetValue(via, out protocol)) { protocol = new RefCountedSecurityProtocol(securityProtocol); this.uri2SecurityProtocol.Add(via, protocol); } else { protocol.AddRef(); } } }