internal override void OnOpen()
        {
            connectionListener = new BufferedConnectionListener(
                new PipeConnectionListener(ListenUri, HostNameComparisonMode, ConnectionBufferSize,
                    AllowedUsers, true, int.MaxValue),
                    MaxOutputDelay, ConnectionBufferSize);
            if (DiagnosticUtility.ShouldUseActivity)
            {
                connectionListener = new TracingConnectionListener(connectionListener, this.ListenUri.ToString(), false);
            }

            connectionDemuxer = new ConnectionDemuxer(connectionListener,
                MaxPendingAccepts, MaxPendingConnections, ChannelInitializationTimeout,
                IdleTimeout, MaxPooledConnections,
                OnGetTransportFactorySettings,
                OnGetSingletonMessageHandler,
                OnHandleServerSessionPreamble,
                OnDemuxerError);

            bool startedDemuxing = false;
            try
            {
                connectionDemuxer.StartDemuxing();
                startedDemuxing = true;
            }
            finally
            {
                if (!startedDemuxing)
                {
                    connectionDemuxer.Dispose();
                }
            }
        }
        internal override void OnOpen()
        {
            connectionListener = new BufferedConnectionListener(
                new PipeConnectionListener(ListenUri, HostNameComparisonMode, ConnectionBufferSize,
                                           AllowedUsers, true, int.MaxValue),
                MaxOutputDelay, ConnectionBufferSize);
            if (DiagnosticUtility.ShouldUseActivity)
            {
                connectionListener = new TracingConnectionListener(connectionListener, this.ListenUri.ToString(), false);
            }

            connectionDemuxer = new ConnectionDemuxer(connectionListener,
                                                      MaxPendingAccepts, MaxPendingConnections, ChannelInitializationTimeout,
                                                      IdleTimeout, MaxPooledConnections,
                                                      OnGetTransportFactorySettings,
                                                      OnGetSingletonMessageHandler,
                                                      OnHandleServerSessionPreamble,
                                                      OnDemuxerError);

            bool startedDemuxing = false;

            try
            {
                connectionDemuxer.StartDemuxing();
                startedDemuxing = true;
            }
            finally
            {
                if (!startedDemuxing)
                {
                    connectionDemuxer.Dispose();
                }
            }
        }
        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 <IDuplexSessionChannel> )
                {
                    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())));
            }
        }
Ejemplo n.º 4
0
        void ISessionPreambleHandler.HandleServerSessionPreamble(ServerSessionPreambleConnectionReader preambleReader,
                                                                 ConnectionDemuxer connectionDemuxer)
        {
            IDuplexSessionChannel channel = preambleReader.CreateDuplexSessionChannel(
                this, new EndpointAddress(this.Uri), ExposeConnectionProperty, connectionDemuxer);

            duplexAcceptor.EnqueueAndDispatch(channel, preambleReader.ConnectionDequeuedCallback);
        }
 public ServerSingletonConnectionReader(ServerSingletonPreambleConnectionReader preambleReader, IConnection upgradedConnection, ConnectionDemuxer connectionDemuxer) : base(upgradedConnection, preambleReader.BufferOffset, preambleReader.BufferSize, preambleReader.Security, preambleReader.TransportSettings, preambleReader.Via)
 {
     this.decoder = preambleReader.Decoder;
     this.contentType = this.decoder.ContentType;
     this.connectionDemuxer = connectionDemuxer;
     this.rawConnection = preambleReader.RawConnection;
     this.channelBindingToken = preambleReader.ChannelBinding;
 }
 public ServerSingletonConnectionReader(ServerSingletonPreambleConnectionReader preambleReader, IConnection upgradedConnection, ConnectionDemuxer connectionDemuxer) : base(upgradedConnection, preambleReader.BufferOffset, preambleReader.BufferSize, preambleReader.Security, preambleReader.TransportSettings, preambleReader.Via)
 {
     this.decoder             = preambleReader.Decoder;
     this.contentType         = this.decoder.ContentType;
     this.connectionDemuxer   = connectionDemuxer;
     this.rawConnection       = preambleReader.RawConnection;
     this.channelBindingToken = preambleReader.ChannelBinding;
 }
 private void CreateConnectionDemuxer()
 {
     IConnectionListener listener = new BufferedConnectionListener(this.listener, base.MaxOutputDelay, base.ConnectionBufferSize);
     if (DiagnosticUtility.ShouldUseActivity)
     {
         listener = new TracingConnectionListener(listener, base.ListenUri);
     }
     this.connectionDemuxer = new ConnectionDemuxer(listener, base.MaxPendingAccepts, base.MaxPendingConnections, base.ChannelInitializationTimeout, base.IdleTimeout, base.MaxPooledConnections, new TransportSettingsCallback(this.OnGetTransportFactorySettings), new SingletonPreambleDemuxCallback(this.OnGetSingletonMessageHandler), new ServerSessionPreambleDemuxCallback(this.OnHandleServerSessionPreamble), new System.ServiceModel.Channels.ErrorCallback(this.OnDemuxerError));
     this.connectionDemuxer.StartDemuxing(this.onViaCallback);
 }
        private void CreateConnectionDemuxer()
        {
            IConnectionListener listener = new BufferedConnectionListener(this.listener, base.MaxOutputDelay, base.ConnectionBufferSize);

            if (DiagnosticUtility.ShouldUseActivity)
            {
                listener = new TracingConnectionListener(listener, this.ListenUri);
            }
            this.connectionDemuxer = new ConnectionDemuxer(listener, base.MaxPendingAccepts, base.MaxPendingConnections, base.ChannelInitializationTimeout, base.IdleTimeout, base.MaxPooledConnections, new TransportSettingsCallback(this.OnGetTransportFactorySettings), new SingletonPreambleDemuxCallback(this.OnGetSingletonMessageHandler), new ServerSessionPreambleDemuxCallback(this.OnHandleServerSessionPreamble), new System.ServiceModel.Channels.ErrorCallback(this.OnDemuxerError));
            this.connectionDemuxer.StartDemuxing(this.GetOnViaCallback());
        }
        internal override void OnOpen()
        {
            SocketConnectionListener socketListener = null;

            if (this.listenSocket != null)
            {
                socketListener    = new SocketConnectionListener(this.listenSocket, this, false);
                this.listenSocket = null;
            }
            else
            {
                int port = this.registration.ListenUri.Port;
                if (port == -1)
                {
                    port = TcpUri.DefaultPort;
                }

                socketListener = new SocketConnectionListener(new IPEndPoint(ipAddress, port), this, false);
            }

            connectionListener = new BufferedConnectionListener(socketListener, MaxOutputDelay, ConnectionBufferSize);
            if (DiagnosticUtility.ShouldUseActivity)
            {
                connectionListener = new TracingConnectionListener(connectionListener, this.registration.ListenUri.ToString(), false);
            }
            connectionDemuxer = new ConnectionDemuxer(connectionListener,
                                                      MaxPendingAccepts, MaxPendingConnections, ChannelInitializationTimeout,
                                                      IdleTimeout, MaxPooledConnections,
                                                      OnGetTransportFactorySettings,
                                                      OnGetSingletonMessageHandler,
                                                      OnHandleServerSessionPreamble,
                                                      OnDemuxerError);

            bool startedDemuxing = false;

            try
            {
                connectionDemuxer.StartDemuxing();
                startedDemuxing = true;
            }
            finally
            {
                if (!startedDemuxing)
                {
                    connectionDemuxer.Dispose();
                }
            }
        }
 public ServerFramingDuplexSessionChannel(ConnectionOrientedTransportChannelListener channelListener, ServerSessionPreambleConnectionReader preambleReader, EndpointAddress localAddress, bool exposeConnectionProperty, ConnectionDemuxer connectionDemuxer) : base(channelListener, localAddress, preambleReader.Via, exposeConnectionProperty)
 {
     this.channelListener = channelListener;
     this.connectionDemuxer = connectionDemuxer;
     base.Connection = preambleReader.Connection;
     this.decoder = preambleReader.Decoder;
     this.connectionBuffer = preambleReader.connectionBuffer;
     this.offset = preambleReader.BufferOffset;
     this.size = preambleReader.BufferSize;
     this.rawConnection = preambleReader.RawConnection;
     StreamUpgradeProvider upgrade = channelListener.Upgrade;
     if (upgrade != null)
     {
         this.channelBindingProvider = upgrade.GetProperty<IStreamUpgradeChannelBindingProvider>();
         this.upgradeAcceptor = upgrade.CreateUpgradeAcceptor();
     }
 }
            public CompleteSingletonPreambleAndDispatchRequestAsyncResult(
                ServerSingletonPreambleConnectionReader serverSingletonPreambleReader,
                ISingletonChannelListener singletonChannelListener,
                ConnectionDemuxer demuxer,
                AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.serverSingletonPreambleReader = serverSingletonPreambleReader;
                this.singletonChannelListener      = singletonChannelListener;
                this.demuxer = demuxer;

                //if this throws, the calling code paths will abort the connection, so we only need to
                //call AbortConnection if BeginCompletePramble completes asynchronously.
                if (BeginCompletePreamble())
                {
                    Complete(true);
                }
            }
Ejemplo n.º 12
0
        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());
        }
Ejemplo n.º 13
0
        internal override void OnOpen()
        {
            SocketConnectionListener connectionListener = null;

            if (this.listenSocket != null)
            {
                connectionListener = new SocketConnectionListener(this.listenSocket, this, false);
                this.listenSocket  = null;
            }
            else
            {
                int port = this.registration.ListenUri.Port;
                if (port == -1)
                {
                    port = 0x328;
                }
                connectionListener = new SocketConnectionListener(new IPEndPoint(this.ipAddress, port), this, false);
            }
            this.connectionListener = new BufferedConnectionListener(connectionListener, base.MaxOutputDelay, base.ConnectionBufferSize);
            if (DiagnosticUtility.ShouldUseActivity)
            {
                this.connectionListener = new TracingConnectionListener(this.connectionListener, this.registration.ListenUri.ToString(), false);
            }
            this.connectionDemuxer = new ConnectionDemuxer(this.connectionListener, base.MaxPendingAccepts, base.MaxPendingConnections, base.ChannelInitializationTimeout, base.IdleTimeout, base.MaxPooledConnections, new TransportSettingsCallback(this.OnGetTransportFactorySettings), new SingletonPreambleDemuxCallback(this.OnGetSingletonMessageHandler), new ServerSessionPreambleDemuxCallback(this.OnHandleServerSessionPreamble), new System.ServiceModel.Channels.ErrorCallback(this.OnDemuxerError));
            bool flag = false;

            try
            {
                this.connectionDemuxer.StartDemuxing();
                flag = true;
            }
            finally
            {
                if (!flag)
                {
                    this.connectionDemuxer.Dispose();
                }
            }
        }
 internal override void OnOpen()
 {
     this.connectionListener = new BufferedConnectionListener(new PipeConnectionListener(base.ListenUri, base.HostNameComparisonMode, base.ConnectionBufferSize, base.AllowedUsers, true, 0x7fffffff), base.MaxOutputDelay, base.ConnectionBufferSize);
     if (DiagnosticUtility.ShouldUseActivity)
     {
         this.connectionListener = new TracingConnectionListener(this.connectionListener, base.ListenUri.ToString(), false);
     }
     this.connectionDemuxer = new ConnectionDemuxer(this.connectionListener, base.MaxPendingAccepts, base.MaxPendingConnections, base.ChannelInitializationTimeout, base.IdleTimeout, base.MaxPooledConnections, new TransportSettingsCallback(this.OnGetTransportFactorySettings), new SingletonPreambleDemuxCallback(this.OnGetSingletonMessageHandler), new ServerSessionPreambleDemuxCallback(this.OnHandleServerSessionPreamble), new System.ServiceModel.Channels.ErrorCallback(this.OnDemuxerError));
     bool flag = false;
     try
     {
         this.connectionDemuxer.StartDemuxing();
         flag = true;
     }
     finally
     {
         if (!flag)
         {
             this.connectionDemuxer.Dispose();
         }
     }
 }
 protected override void ReturnConnectionIfNecessary(bool abort, TimeSpan timeout)
 {
     IConnection rawConnection = null;
     if (this.sessionReader != null)
     {
         lock (base.ThisLock)
         {
             rawConnection = this.sessionReader.GetRawConnection();
         }
     }
     if (rawConnection != null)
     {
         if (abort)
         {
             rawConnection.Abort();
         }
         else
         {
             this.connectionDemuxer.ReuseConnection(rawConnection, timeout);
         }
         this.connectionDemuxer = null;
     }
 }
        internal override void OnOpen()
        {
            this.connectionListener = new BufferedConnectionListener(new PipeConnectionListener(base.ListenUri, base.HostNameComparisonMode, base.ConnectionBufferSize, base.AllowedUsers, true, 0x7fffffff), base.MaxOutputDelay, base.ConnectionBufferSize);
            if (DiagnosticUtility.ShouldUseActivity)
            {
                this.connectionListener = new TracingConnectionListener(this.connectionListener, base.ListenUri.ToString(), false);
            }
            this.connectionDemuxer = new ConnectionDemuxer(this.connectionListener, base.MaxPendingAccepts, base.MaxPendingConnections, base.ChannelInitializationTimeout, base.IdleTimeout, base.MaxPooledConnections, new TransportSettingsCallback(this.OnGetTransportFactorySettings), new SingletonPreambleDemuxCallback(this.OnGetSingletonMessageHandler), new ServerSessionPreambleDemuxCallback(this.OnHandleServerSessionPreamble), new System.ServiceModel.Channels.ErrorCallback(this.OnDemuxerError));
            bool flag = false;

            try
            {
                this.connectionDemuxer.StartDemuxing();
                flag = true;
            }
            finally
            {
                if (!flag)
                {
                    this.connectionDemuxer.Dispose();
                }
            }
        }
        static void OnSingletonPreambleComplete(IAsyncResult result)
        {
            if (result.CompletedSynchronously)
            {
                return;
            }

            ConnectionDemuxer thisPtr = (ConnectionDemuxer)result.AsyncState;

            try
            {
                thisPtr.EndCompleteSingletonPreamble(result);
            }
            catch (Exception ex)
            {
                if (Fx.IsFatal(ex))
                {
                    throw;
                }

                //should never actually hit this code - the async result will handle all exceptions, trace them, then abort the reader
                DiagnosticUtility.TraceHandledException(ex, TraceEventType.Warning);
            }
        }
 internal override void OnOpen()
 {
     SocketConnectionListener connectionListener = null;
     if (this.listenSocket != null)
     {
         connectionListener = new SocketConnectionListener(this.listenSocket, this, false);
         this.listenSocket = null;
     }
     else
     {
         int port = this.registration.ListenUri.Port;
         if (port == -1)
         {
             port = 0x328;
         }
         connectionListener = new SocketConnectionListener(new IPEndPoint(this.ipAddress, port), this, false);
     }
     this.connectionListener = new BufferedConnectionListener(connectionListener, base.MaxOutputDelay, base.ConnectionBufferSize);
     if (DiagnosticUtility.ShouldUseActivity)
     {
         this.connectionListener = new TracingConnectionListener(this.connectionListener, this.registration.ListenUri.ToString(), false);
     }
     this.connectionDemuxer = new ConnectionDemuxer(this.connectionListener, base.MaxPendingAccepts, base.MaxPendingConnections, base.ChannelInitializationTimeout, base.IdleTimeout, base.MaxPooledConnections, new TransportSettingsCallback(this.OnGetTransportFactorySettings), new SingletonPreambleDemuxCallback(this.OnGetSingletonMessageHandler), new ServerSessionPreambleDemuxCallback(this.OnHandleServerSessionPreamble), new System.ServiceModel.Channels.ErrorCallback(this.OnDemuxerError));
     bool flag = false;
     try
     {
         this.connectionDemuxer.StartDemuxing();
         flag = true;
     }
     finally
     {
         if (!flag)
         {
             this.connectionDemuxer.Dispose();
         }
     }
 }
Ejemplo n.º 19
0
        internal void OnHandleServerSessionPreamble(ServerSessionPreambleConnectionReader serverSessionPreambleReader, ConnectionDemuxer connectionDemuxer)
        {
            Uri via = serverSessionPreambleReader.Via;
            TChannelListener channelListener = this.GetChannelListener(via);

            if (channelListener != null)
            {
                ISessionPreambleHandler handler = channelListener as ISessionPreambleHandler;
                if ((handler != null) && (channelListener is IChannelListener <IDuplexSessionChannel>))
                {
                    handler.HandleServerSessionPreamble(serverSessionPreambleReader, connectionDemuxer);
                    return;
                }
                serverSessionPreambleReader.SendFault("http://schemas.microsoft.com/ws/2006/05/framing/faults/UnsupportedMode");
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ProtocolException(System.ServiceModel.SR.GetString("FramingModeNotSupported", new object[] { FramingMode.Duplex })));
            }
            serverSessionPreambleReader.SendFault("http://schemas.microsoft.com/ws/2006/05/framing/faults/EndpointNotFound");
            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new EndpointNotFoundException(System.ServiceModel.SR.GetString("DuplexSessionListenerNotFound", new object[] { via.ToString() })));
        }
        internal override void OnOpen()
        {
            SocketConnectionListener socketListener = null;

            if (this.listenSocket != null)
            {
                socketListener = new SocketConnectionListener(this.listenSocket, this, false);
                this.listenSocket = null;
            }
            else
            {
                int port = this.registration.ListenUri.Port;
                if (port == -1)
                    port = TcpUri.DefaultPort;

                socketListener = new SocketConnectionListener(new IPEndPoint(ipAddress, port), this, false);
            }

            connectionListener = new BufferedConnectionListener(socketListener, MaxOutputDelay, ConnectionBufferSize);
            if (DiagnosticUtility.ShouldUseActivity)
            {
                connectionListener = new TracingConnectionListener(connectionListener, this.registration.ListenUri.ToString(), false);
            }
            connectionDemuxer = new ConnectionDemuxer(connectionListener,
                MaxPendingAccepts, MaxPendingConnections, ChannelInitializationTimeout,
                IdleTimeout, MaxPooledConnections,
                OnGetTransportFactorySettings,
                OnGetSingletonMessageHandler,
                OnHandleServerSessionPreamble,
                OnDemuxerError);

            bool startedDemuxing = false;
            try
            {
                connectionDemuxer.StartDemuxing();
                startedDemuxing = true;
            }
            finally
            {
                if (!startedDemuxing)
                {
                    connectionDemuxer.Dispose();
                }
            }
        }
            public CompleteSingletonPreambleAndDispatchRequestAsyncResult(
                ServerSingletonPreambleConnectionReader serverSingletonPreambleReader,
                ISingletonChannelListener singletonChannelListener,
                ConnectionDemuxer demuxer,
                AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.serverSingletonPreambleReader = serverSingletonPreambleReader;
                this.singletonChannelListener = singletonChannelListener;
                this.demuxer = demuxer;

                //if this throws, the calling code paths will abort the connection, so we only need to 
                //call AbortConnection if BeginCompletePramble completes asynchronously.
                if (BeginCompletePreamble())
                {
                    Complete(true);
                }
            }
        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);
        }
 public IDuplexSessionChannel CreateDuplexSessionChannel(ConnectionOrientedTransportChannelListener channelListener, EndpointAddress localAddress, bool exposeConnectionProperty, ConnectionDemuxer connectionDemuxer)
 {
     return new ServerFramingDuplexSessionChannel(channelListener, this, localAddress, exposeConnectionProperty, connectionDemuxer);
 }