Exemple #1
0
 internal void CopyTimeouts(IDefaultCommunicationTimeouts source)
 {
     this.CloseTimeout   = source.CloseTimeout;
     this.OpenTimeout    = source.OpenTimeout;
     this.ReceiveTimeout = source.ReceiveTimeout;
     this.SendTimeout    = source.SendTimeout;
 }
Exemple #2
0
        protected TransportOutputChannel(IDefaultCommunicationTimeouts timeouts, EndpointAddress to, Uri via, bool manualAddressing, MessageVersion messageVersion)
            : base(timeouts)
        {
            ManualAddressing = manualAddressing;
            MessageVersion   = messageVersion;
            _to  = to;
            _via = via;

            if (!manualAddressing && _to != null)
            {
                Uri toUri;
                if (_to.IsAnonymous)
                {
                    toUri = MessageVersion.Addressing.AnonymousUri;
                }
                else if (_to.IsNone)
                {
                    toUri = MessageVersion.Addressing.NoneUri;
                }
                else
                {
                    toUri = _to.Uri;
                }

                if (toUri != null)
                {
                    XmlDictionaryString dictionaryTo = new ToDictionary(toUri.AbsoluteUri).To;
                    _toHeader = ToHeader.Create(toUri, dictionaryTo, messageVersion.Addressing);
                }

                _anyHeadersToAdd = _to.Headers.Count > 0;
            }
        }
Exemple #3
0
 private SslStreamSecurityUpgradeProvider(IDefaultCommunicationTimeouts timeouts, SecurityTokenManager clientSecurityTokenManager, bool requireClientCertificate, string scheme, System.ServiceModel.Security.IdentityVerifier identityVerifier) : base(timeouts)
 {
     this.identityVerifier           = identityVerifier;
     this.scheme                     = scheme;
     this.clientSecurityTokenManager = clientSecurityTokenManager;
     this.requireClientCertificate   = requireClientCertificate;
 }
        internal ListenerHandler(IListenerBinder listenerBinder, ChannelDispatcher channelDispatcher, ServiceHostBase host, ServiceThrottle throttle, IDefaultCommunicationTimeouts timeouts)
        {
            this.listenerBinder = listenerBinder;
            if (!((this.listenerBinder != null)))
            {
                Fx.Assert("ListenerHandler.ctor: (this.listenerBinder != null)");
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("listenerBinder");
            }

            this.channelDispatcher = channelDispatcher;
            if (!((this.channelDispatcher != null)))
            {
                Fx.Assert("ListenerHandler.ctor: (this.channelDispatcher != null)");
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channelDispatcher");
            }

            this.host = host;
            if (!((this.host != null)))
            {
                Fx.Assert("ListenerHandler.ctor: (this.host != null)");
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("host");
            }

            this.throttle = throttle;
            if (!((this.throttle != null)))
            {
                Fx.Assert("ListenerHandler.ctor: (this.throttle != null)");
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("throttle");
            }

            this.timeouts = timeouts;

            this.endpoints = channelDispatcher.EndpointDispatcherTable;
            this.acceptor  = new ErrorHandlingAcceptor(listenerBinder, channelDispatcher);
        }
 public DefaultCommunicationTimeouts(IDefaultCommunicationTimeouts timeouts)
 {
     _closeTimeout   = timeouts.CloseTimeout;
     _openTimeout    = timeouts.OpenTimeout;
     _receiveTimeout = timeouts.ReceiveTimeout;
     _sendTimeout    = timeouts.SendTimeout;
 }
Exemple #6
0
        public static bool InitiateUpgrade(StreamUpgradeInitiator upgradeInitiator, ref IConnection connection,
                                           ClientFramingDecoder decoder, IDefaultCommunicationTimeouts defaultTimeouts, ref TimeoutHelper timeoutHelper)
        {
            string upgradeContentType = upgradeInitiator.GetNextUpgrade();

            while (upgradeContentType != null)
            {
                EncodedUpgrade encodedUpgrade = new EncodedUpgrade(upgradeContentType);
                // write upgrade request framing for synchronization
                connection.Write(encodedUpgrade.EncodedBytes, 0, encodedUpgrade.EncodedBytes.Length, true, timeoutHelper.RemainingTime());
                byte[] buffer = new byte[1];

                // read upgrade response framing
                int size = connection.Read(buffer, 0, buffer.Length, timeoutHelper.RemainingTime());

                if (!ValidateUpgradeResponse(buffer, size, decoder)) // we have a problem
                {
                    return(false);
                }

                // initiate wire upgrade
                ConnectionStream connectionStream = new ConnectionStream(connection, defaultTimeouts);
                Stream           upgradedStream   = upgradeInitiator.InitiateUpgrade(connectionStream);

                // and re-wrap connection
                connection = new StreamConnection(upgradedStream, connectionStream);

                upgradeContentType = upgradeInitiator.GetNextUpgrade();
            }

            return(true);
        }
Exemple #7
0
 public InitiateSecureClientUpgradeClientSideAsyncResult(IConnection connection, IDefaultCommunicationTimeouts defaultTimeouts, SocketSecurityRole socketSecurityMode, string targetHost, TimeSpan timeout, AsyncCallback callback, object state) : base(timeout, callback, state)
 {
     this.connection         = connection;
     this.defaultTimeouts    = defaultTimeouts;
     this.socketSecurityMode = socketSecurityMode;
     this.targetHost         = targetHost;
 }
Exemple #8
0
 public RequestDelegateHandler(IServiceDispatcher serviceDispatcher, IServiceScopeFactory servicesScopeFactory)
 {
     _serviceDispatcher    = serviceDispatcher;
     _timeouts             = _serviceDispatcher.Binding;
     _servicesScopeFactory = servicesScopeFactory;
     BuildHandler();
 }
		protected StreamUpgradeProvider (IDefaultCommunicationTimeouts timeouts)
		{
			if (timeouts == null)
				throw new ArgumentNullException ("timeouts");
			default_open_timeout = timeouts.OpenTimeout;
			default_close_timeout = timeouts.CloseTimeout;
		}
 internal ListenerHandler(IListenerBinder listenerBinder, System.ServiceModel.Dispatcher.ChannelDispatcher channelDispatcher, ServiceHostBase host, ServiceThrottle throttle, IDefaultCommunicationTimeouts timeouts)
 {
     this.listenerBinder = listenerBinder;
     if (this.listenerBinder == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("listenerBinder");
     }
     this.channelDispatcher = channelDispatcher;
     if (this.channelDispatcher == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channelDispatcher");
     }
     this.host = host;
     if (this.host == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("host");
     }
     this.throttle = throttle;
     if (this.throttle == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("throttle");
     }
     this.timeouts = timeouts;
     this.endpoints = channelDispatcher.EndpointDispatcherTable;
     this.acceptor = new ErrorHandlingAcceptor(listenerBinder, channelDispatcher);
 }
        protected HttpTransportBindingElement(
            HttpTransportBindingElement other)
            : base(other)
        {
            allow_cookies         = other.allow_cookies;
            bypass_proxy_on_local = other.bypass_proxy_on_local;
            unsafe_ntlm_auth      = other.unsafe_ntlm_auth;
            use_default_proxy     = other.use_default_proxy;
            keep_alive_enabled    = other.keep_alive_enabled;
            max_buffer_size       = other.max_buffer_size;
            host_cmp_mode         = other.host_cmp_mode;
            proxy_address         = other.proxy_address;
            realm         = other.realm;
            transfer_mode = other.transfer_mode;
            // FIXME: it does not look safe
            timeouts          = other.timeouts;
            auth_scheme       = other.auth_scheme;
            proxy_auth_scheme = other.proxy_auth_scheme;

#if NET_4_0
            DecompressionEnabled           = other.DecompressionEnabled;
            LegacyExtendedProtectionPolicy = other.LegacyExtendedProtectionPolicy;
            ExtendedProtectionPolicy       = other.ExtendedProtectionPolicy;
            cookie_manager = other.cookie_manager;
#endif
        }
 public DefaultCommunicationTimeouts(IDefaultCommunicationTimeouts timeouts)
 {
     this.closeTimeout   = timeouts.CloseTimeout;
     this.openTimeout    = timeouts.OpenTimeout;
     this.receiveTimeout = timeouts.ReceiveTimeout;
     this.sendTimeout    = timeouts.SendTimeout;
 }
Exemple #13
0
        public static async Task WriteMessageAsync(Message message, FramingConnection connection, bool isRequest,
                                                   IDefaultCommunicationTimeouts settings, CancellationToken token)
        {
            byte[] endBytes = null;
            if (message != null)
            {
                MessageEncoder messageEncoder     = connection.MessageEncoderFactory.Encoder;
                byte[]         envelopeStartBytes = SingletonEncoder.EnvelopeStartBytes;

                bool writeStreamed;
                if (isRequest)
                {
                    endBytes      = SingletonEncoder.EnvelopeEndFramingEndBytes;
                    writeStreamed = TransferModeHelper.IsRequestStreamed(connection.TransferMode);
                }
                else
                {
                    endBytes      = SingletonEncoder.EnvelopeEndBytes;
                    writeStreamed = TransferModeHelper.IsResponseStreamed(connection.TransferMode);
                }

                if (writeStreamed)
                {
                    await connection.Output.WriteAsync(envelopeStartBytes, token);

                    Stream connectionStream = new StreamingOutputConnectionStream(connection, settings);
                    // TODO: Determine if timeout stream is needed as StreamingOutputConnectionStream implements some timeout functionality
                    //Stream writeTimeoutStream = new TimeoutStream(connectionStream, ref timeoutHelper);
                    await messageEncoder.WriteMessageAsync(message, connectionStream);

                    await connection.Output.FlushAsync();
                }
                else
                {
                    ArraySegment <byte> messageData = messageEncoder.WriteMessage(message,
                                                                                  int.MaxValue, connection.BufferManager, envelopeStartBytes.Length + IntEncoder.MaxEncodedSize);
                    messageData = SingletonEncoder.EncodeMessageFrame(messageData);
                    Buffer.BlockCopy(envelopeStartBytes, 0, messageData.Array, messageData.Offset - envelopeStartBytes.Length,
                                     envelopeStartBytes.Length);
                    await connection.Output.WriteAsync(new ArraySegment <byte>(messageData.Array, messageData.Offset - envelopeStartBytes.Length,
                                                                               messageData.Count + envelopeStartBytes.Length), token);

                    await connection.Output.FlushAsync();

                    connection.BufferManager.ReturnBuffer(messageData.Array);
                }
            }
            else if (isRequest) // context handles response end bytes
            {
                endBytes = SingletonEncoder.EndBytes;
            }

            if (endBytes != null)
            {
                await connection.Output.WriteAsync(endBytes, token);

                await connection.Output.FlushAsync();
            }
        }
 public ConnectionStream(IConnection connection, IDefaultCommunicationTimeouts defaultTimeouts)
 {
     this.connection = connection;
     this.closeTimeout = defaultTimeouts.CloseTimeout;
     this.ReadTimeout = TimeoutHelper.ToMilliseconds(defaultTimeouts.ReceiveTimeout);
     this.WriteTimeout = TimeoutHelper.ToMilliseconds(defaultTimeouts.SendTimeout);
     this.immediate = true;
 }
Exemple #15
0
 protected ChannelListenerBase(IDefaultCommunicationTimeouts timeouts)
 {
     if (timeouts == null)
     {
         throw new ArgumentNullException("timeouts");
     }
     this.timeouts = timeouts;
 }
 public WebSocketMessageSource(WebSocketTransportDuplexSessionChannel webSocketTransportDuplexSessionChannel, WebSocket webSocket,
                               bool useStreaming, IDefaultCommunicationTimeouts defaultTimeouts)
 {
     Initialize(webSocketTransportDuplexSessionChannel, webSocket, useStreaming, defaultTimeouts);
     // TODO: Switch IMessageSource to use TimeSpan instead of CancellationToken. See Issue #283
     _asyncReceiveTimeout = TimeSpan.Zero;
     StartNextReceiveAsync();
 }
Exemple #17
0
 protected ChannelFactoryBase(IDefaultCommunicationTimeouts timeouts)
 {
     this.closeTimeout   = ServiceDefaults.CloseTimeout;
     this.openTimeout    = ServiceDefaults.OpenTimeout;
     this.receiveTimeout = ServiceDefaults.ReceiveTimeout;
     this.sendTimeout    = ServiceDefaults.SendTimeout;
     this.InitializeTimeouts(timeouts);
 }
 internal ChannelDispatcher(Uri listenUri, Binding binding, string bindingName, IDefaultCommunicationTimeouts timeouts)
 {
     BindingName   = bindingName;
     Binding       = binding;
     ListenUri     = listenUri;
     this.timeouts = new ImmutableCommunicationTimeouts(timeouts);
     Initialize(new SharedRuntimeState(true));
 }
Exemple #19
0
 public ConnectionStream(IConnection connection, IDefaultCommunicationTimeouts defaultTimeouts)
 {
     this.connection   = connection;
     this.closeTimeout = defaultTimeouts.CloseTimeout;
     this.ReadTimeout  = TimeoutHelper.ToMilliseconds(defaultTimeouts.ReceiveTimeout);
     this.WriteTimeout = TimeoutHelper.ToMilliseconds(defaultTimeouts.SendTimeout);
     immediate         = true;
 }
Exemple #20
0
        public TransactionChannelListener(TransactionProtocol transactionProtocol, IDefaultCommunicationTimeouts timeouts, Dictionary <DirectionalAction, TransactionFlowOption> dictionary, IChannelListener <TChannel> innerListener)
            : base(timeouts, innerListener)
        {
            this.dictionary          = dictionary;
            this.TransactionProtocol = transactionProtocol;
            this.Acceptor            = new TransactionChannelAcceptor(this, innerListener);

            this.standardsManager = SecurityStandardsHelper.CreateStandardsManager(this.TransactionProtocol);
        }
 public ServiceChannelFactory(ClientRuntime clientRuntime, Binding binding)
     : base()
 {
     _bindingName   = binding.Name;
     _channelsList  = new List <IChannel>();
     _clientRuntime = clientRuntime ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(clientRuntime));
     _timeouts      = new DefaultCommunicationTimeouts(binding);
     MessageVersion = binding.MessageVersion;
 }
 public SingletonInputConnectionStream(SingletonConnectionReader reader, IConnection connection,
                                       IDefaultCommunicationTimeouts defaultTimeouts)
     : base(connection, defaultTimeouts)
 {
     _reader              = reader;
     _decoder             = new SingletonMessageDecoder(reader.StreamPosition);
     _chunkBytesRemaining = 0;
     _chunkBuffer         = new byte[IntEncoder.MaxEncodedSize];
 }
 public SingletonInputConnectionStream(FramingConnection connection,
                                       IDefaultCommunicationTimeouts defaultTimeouts)
 {
     _connection         = connection;
     _timeouts           = defaultTimeouts;
     decoder             = new SingletonMessageDecoder();
     chunkBytesRemaining = 0;
     _timeoutHelper      = new TimeoutHelper(_timeouts.ReceiveTimeout);
 }
 private SslStreamSecurityUpgradeProvider(IDefaultCommunicationTimeouts timeouts, SecurityTokenManager clientSecurityTokenManager, bool requireClientCertificate, string scheme, IdentityVerifier identityVerifier, SslProtocols sslProtocols)
     : base(timeouts)
 {
     _identityVerifier           = identityVerifier;
     _scheme                     = scheme;
     _clientSecurityTokenManager = clientSecurityTokenManager;
     _requireClientCertificate   = requireClientCertificate;
     _sslProtocols               = sslProtocols;
 }
Exemple #25
0
 protected StreamUpgradeProvider(IDefaultCommunicationTimeouts timeouts)
 {
     if (timeouts == null)
     {
         throw new ArgumentNullException("timeouts");
     }
     default_open_timeout  = timeouts.OpenTimeout;
     default_close_timeout = timeouts.CloseTimeout;
 }
 protected ChannelListenerBase(IDefaultCommunicationTimeouts timeouts)
 {
     if (timeouts != null)
     {
         closeTimeout   = timeouts.CloseTimeout;
         openTimeout    = timeouts.OpenTimeout;
         receiveTimeout = timeouts.ReceiveTimeout;
         sendTimeout    = timeouts.SendTimeout;
     }
 }
Exemple #27
0
 protected LayeredChannelListener(bool sharedInnerListener, IDefaultCommunicationTimeouts timeouts, IChannelListener innerChannelListener) : base(timeouts)
 {
     this.sharedInnerListener    = sharedInnerListener;
     this.innerChannelListener   = innerChannelListener;
     this.onInnerListenerFaulted = new EventHandler(this.OnInnerListenerFaulted);
     if (this.innerChannelListener != null)
     {
         this.innerChannelListener.Faulted += this.onInnerListenerFaulted;
     }
 }
Exemple #28
0
 private void InitializeTimeouts(IDefaultCommunicationTimeouts timeouts)
 {
     if (timeouts != null)
     {
         _closeTimeout   = timeouts.CloseTimeout;
         _openTimeout    = timeouts.OpenTimeout;
         _receiveTimeout = timeouts.ReceiveTimeout;
         _sendTimeout    = timeouts.SendTimeout;
     }
 }
 public ChannelDispatcher(
     IChannelListener listener, string bindingName,
     IDefaultCommunicationTimeouts timeouts)
 {
     if (listener == null)
     {
         throw new ArgumentNullException("listener");
     }
     Init(listener, bindingName, timeouts);
 }
Exemple #30
0
        private void Initialize()
        {
            IDefaultCommunicationTimeouts t =
                DefaultCommunicationTimeouts.Instance;

            open_timeout    = t.OpenTimeout;
            close_timeout   = t.CloseTimeout;
            receive_timeout = t.ReceiveTimeout;
            send_timeout    = t.SendTimeout;
        }
 public RelayHttpTransportRequestContext(RequestContext innerContext, IDefaultCommunicationTimeouts defaultTimeouts, MessageEncoder encoder, bool preserveRawHttp)
 {
     this.preserveRawHttp = preserveRawHttp;
     this.innerContext    = innerContext;
     this.defaultTimeouts = defaultTimeouts;
     this.encoder         = encoder;
     this.wrapper         = new MessageWrapper(this.encoder);
     this.requestAction   = this.innerContext.RequestMessage.Headers.Action;
     this.requestMessage  = this.PrepareRequest(this.innerContext.RequestMessage);
 }
 private void Init(IChannelListener listener, string bindingName,
                   IDefaultCommunicationTimeouts timeouts)
 {
     this.listener     = listener;
     this.binding_name = bindingName;
     // IChannelListener is often a ChannelListenerBase
     // which implements IDefaultCommunicationTimeouts.
     this.timeouts = timeouts ?? listener as IDefaultCommunicationTimeouts ?? DefaultCommunicationTimeouts.Instance;
     endpoints     = new EndpointDispatcherCollection(this);
 }
 private SslStreamSecurityUpgradeProvider(IDefaultCommunicationTimeouts timeouts, SecurityTokenProvider serverTokenProvider, bool requireClientCertificate, SecurityTokenAuthenticator clientCertificateAuthenticator, string scheme, IdentityVerifier identityVerifier, SslProtocols sslProtocols)
     : base(timeouts)
 {
     _serverTokenProvider            = serverTokenProvider;
     RequireClientCertificate        = requireClientCertificate;
     _clientCertificateAuthenticator = clientCertificateAuthenticator;
     IdentityVerifier = identityVerifier;
     Scheme           = scheme;
     SslProtocols     = sslProtocols;
 }
        public static IDuplexSession CreateClientSession(IDefaultCommunicationTimeouts timeouts, ISession innerSession)
        {
            if (innerSession is ISecureConversationSession)
            {
                return new MakeConnectionDuplexSecureConversationSession(timeouts, innerSession);
            }
            else if (innerSession is ISecuritySession)
            {
                return new MakeConnectionDuplexSecuritySession(timeouts, innerSession);
            }

            return new MakeConnectionDuplexSession(timeouts, innerSession);
        }
 internal ImmutableCommunicationTimeouts(IDefaultCommunicationTimeouts timeouts)
 {
     if (timeouts == null)
     {
         _close = ServiceDefaults.CloseTimeout;
         _open = ServiceDefaults.OpenTimeout;
         _receive = ServiceDefaults.ReceiveTimeout;
         _send = ServiceDefaults.SendTimeout;
     }
     else
     {
         _close = timeouts.CloseTimeout;
         _open = timeouts.OpenTimeout;
         _receive = timeouts.ReceiveTimeout;
         _send = timeouts.SendTimeout;
     }
 }
 public static bool InitiateUpgrade(StreamUpgradeInitiator upgradeInitiator, ref IConnection connection, ClientFramingDecoder decoder, IDefaultCommunicationTimeouts defaultTimeouts, ref TimeoutHelper timeoutHelper)
 {
     for (string str = upgradeInitiator.GetNextUpgrade(); str != null; str = upgradeInitiator.GetNextUpgrade())
     {
         EncodedUpgrade upgrade = new EncodedUpgrade(str);
         connection.Write(upgrade.EncodedBytes, 0, upgrade.EncodedBytes.Length, true, timeoutHelper.RemainingTime());
         byte[] buffer = new byte[1];
         int count = connection.Read(buffer, 0, buffer.Length, timeoutHelper.RemainingTime());
         if (!ValidateUpgradeResponse(buffer, count, decoder))
         {
             return false;
         }
         ConnectionStream stream = new ConnectionStream(connection, defaultTimeouts);
         Stream stream2 = upgradeInitiator.InitiateUpgrade(stream);
         connection = new StreamConnection(stream2, stream);
     }
     return true;
 }
Exemple #37
0
        internal ListenerHandler(IListenerBinder listenerBinder, ChannelDispatcher channelDispatcher, IDefaultCommunicationTimeouts timeouts)
        {
            _listenerBinder = listenerBinder;
            if (!((_listenerBinder != null)))
            {
                Fx.Assert("ListenerHandler.ctor: (this.listenerBinder != null)");
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("listenerBinder");
            }

            _channelDispatcher = channelDispatcher;
            if (!((_channelDispatcher != null)))
            {
                Fx.Assert("ListenerHandler.ctor: (this.channelDispatcher != null)");
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channelDispatcher");
            }

            _timeouts = timeouts;

            _endpoints = channelDispatcher.EndpointDispatcherTable;
        }
        public MakeConnectionRequestContext(MakeConnectionDispatcherManager dispatcherManager, RequestContext innerContext, TimeSpan pollTimeout, IDefaultCommunicationTimeouts timeouts)
        {
            this.innerContext = innerContext;
            this.pollTimeout = pollTimeout;
            this.timeouts = timeouts;
            this.thisLock = new object();

            if (this.RequestMessage != null)
            {
                this.IsMakeConnectionPollingMessage = (this.RequestMessage.Headers.Action == MakeConnectionConstants.MakeConnectionMessage.Action);
                this.RequestMesssageId = this.RequestMessage.Headers.MessageId;

                EndpointAddress address = GetAddress();

                if (address != null && this.addressIsAnonymousUri)
                {
                    this.dispatcher = dispatcherManager.Get(address.Uri);
                    if (this.RequestMesssageId != null)
                    {
                        this.dispatcher.AddContext(this);
                    }
                }
            }
        }
Exemple #39
0
		protected InternalRequestContext (IDefaultCommunicationTimeouts timeouts)
		{
			this.timeouts = timeouts;
		}
 public static IAsyncResult BeginInitiateUpgrade(IDefaultCommunicationTimeouts timeouts, EndpointAddress remoteAddress, IConnection connection, ClientFramingDecoder decoder, StreamUpgradeInitiator upgradeInitiator, string contentType, WindowsIdentity identityToImpersonate, TimeoutHelper timeoutHelper, AsyncCallback callback, object state)
 {
     return new InitiateUpgradeAsyncResult(timeouts, remoteAddress, connection, decoder, upgradeInitiator, contentType, identityToImpersonate, timeoutHelper, callback, state);
 }
 public InitiateUpgradeAsyncResult(IDefaultCommunicationTimeouts timeouts, EndpointAddress remoteAddress, IConnection connection, ClientFramingDecoder decoder, StreamUpgradeInitiator upgradeInitiator, string contentType, WindowsIdentity identityToImpersonate, TimeoutHelper timeoutHelper, AsyncCallback callback, object state) : base(callback, state)
 {
     this.defaultTimeouts = timeouts;
     this.decoder = decoder;
     this.upgradeInitiator = upgradeInitiator;
     this.contentType = contentType;
     this.timeoutHelper = timeoutHelper;
     this.connection = connection;
     this.remoteAddress = remoteAddress;
     this.identityToImpersonate = identityToImpersonate;
     if (this.Begin())
     {
         base.Complete(true);
     }
 }
            public UpgradeConnectionAsyncResult(IConnection connection,
                StreamUpgradeAcceptor upgradeAcceptor, IDefaultCommunicationTimeouts defaultTimeouts,
                AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.upgradeAcceptor = upgradeAcceptor;
                this.connectionStream = new ConnectionStream(connection, defaultTimeouts);
                bool completeSelf = false;

                IAsyncResult result = upgradeAcceptor.BeginAcceptUpgrade(connectionStream, onAcceptUpgrade, this);

                if (result.CompletedSynchronously)
                {
                    CompleteAcceptUpgrade(result);
                    completeSelf = true;
                }

                if (completeSelf)
                {
                    base.Complete(true);
                }
            }
 MakeConnectionDuplexSession(IDefaultCommunicationTimeouts timeouts, ISession innerSession)
 {
     this.closeTimeout = timeouts.CloseTimeout;
     this.innerSession = innerSession;
 }
 public static IAsyncResult BeginUpgradeConnection(IConnection connection, StreamUpgradeAcceptor upgradeAcceptor,
     IDefaultCommunicationTimeouts defaultTimeouts, AsyncCallback callback, object state)
 {
     return new UpgradeConnectionAsyncResult(connection, upgradeAcceptor, defaultTimeouts, callback, state);
 }
            public WebSocketMessageSource(WebSocketTransportDuplexSessionChannel webSocketTransportDuplexSessionChannel, WebSocket webSocket,
                    bool useStreaming, IDefaultCommunicationTimeouts defaultTimeouts)
            {
                Initialize(webSocketTransportDuplexSessionChannel, webSocket, useStreaming, defaultTimeouts);

                StartNextReceiveAsync();
            }
 void Initialize(WebSocketTransportDuplexSessionChannel webSocketTransportDuplexSessionChannel, WebSocket webSocket, bool useStreaming, IDefaultCommunicationTimeouts defaultTimeouts)
 {
     _webSocket = webSocket;
     _encoder = webSocketTransportDuplexSessionChannel.MessageEncoder;
     _bufferManager = webSocketTransportDuplexSessionChannel.BufferManager;
     _localAddress = webSocketTransportDuplexSessionChannel.LocalAddress;
     _maxBufferSize = webSocketTransportDuplexSessionChannel.MaxBufferSize;
     _maxReceivedMessageSize = webSocketTransportDuplexSessionChannel.TransportFactorySettings.MaxReceivedMessageSize;
     _receiveBufferSize = Math.Min(WebSocketHelper.GetReceiveBufferSize(_maxReceivedMessageSize), _maxBufferSize);
     _useStreaming = useStreaming;
     _defaultTimeouts = defaultTimeouts;
     _closeDetails = webSocketTransportDuplexSessionChannel._webSocketCloseDetails;
     _asyncReceiveTimeout = _defaultTimeouts.ReceiveTimeout; 
     _asyncReceiveState = AsyncReceiveState.Finished;
 }
 public SingletonInputConnectionStream(SingletonConnectionReader reader, IConnection connection, IDefaultCommunicationTimeouts defaultTimeouts) : base(connection, defaultTimeouts)
 {
     this.reader = reader;
     this.decoder = new SingletonMessageDecoder(reader.StreamPosition);
     this.chunkBytesRemaining = 0;
     this.chunkBuffer = new byte[5];
 }
 public SingletonInputConnectionStream(SingletonConnectionReader reader, IConnection connection,
     IDefaultCommunicationTimeouts defaultTimeouts)
     : base(connection, defaultTimeouts)
 {
     _reader = reader;
     _decoder = new SingletonMessageDecoder(reader.StreamPosition);
     _chunkBytesRemaining = 0;
     _chunkBuffer = new byte[IntEncoder.MaxEncodedSize];
 }
 public StreamingOutputConnectionStream(IConnection connection, IDefaultCommunicationTimeouts timeouts)
     : base(connection, timeouts)
 {
     _encodedSize = new byte[IntEncoder.MaxEncodedSize];
 }
 public MakeConnectionDuplexSecuritySession(IDefaultCommunicationTimeouts timeouts, ISession innerSession)
     : base(timeouts, innerSession)
 {
 }
        public static IConnection UpgradeConnection(IConnection connection, StreamUpgradeAcceptor upgradeAcceptor, IDefaultCommunicationTimeouts defaultTimeouts)
        {
            ConnectionStream connectionStream = new ConnectionStream(connection, defaultTimeouts);
            Stream stream = upgradeAcceptor.AcceptUpgrade(connectionStream);
            if (upgradeAcceptor is StreamSecurityUpgradeAcceptor)
            {
                if (DiagnosticUtility.ShouldTraceInformation)
                {
                    TraceUtility.TraceEvent(TraceEventType.Information,
                        TraceCode.StreamSecurityUpgradeAccepted, SR.GetString(SR.TraceCodeStreamSecurityUpgradeAccepted),
                        new StringTraceRecord("Type", upgradeAcceptor.GetType().ToString()), connection, null);
                }
            }

            return new StreamConnection(stream, connectionStream);
        }
 public StreamingOutputConnectionStream(IConnection connection, IDefaultCommunicationTimeouts timeouts) : base(connection, timeouts)
 {
     this.encodedSize = new byte[5];
 }
 protected StreamSecurityUpgradeProvider(IDefaultCommunicationTimeouts timeouts)
     : base(timeouts)
 {
 }