public void ConnectToServer( string host, int port, IHttpResponseFilter filter, Action<bool> callback )
        {
            Logger.Verbose("Waiting for HTTP response semaphore");

            if ( host == _host
                 && port == _port
                && _activeServer != null)
            {
                Logger.Info( "Reusing existing connection" );
                callback( true );
            }
            else
            {
                // Block other connections until this is established. Protect member variables...
                _connectingToRemoteHost.WaitOne();

                Logger.Info("Server Dispatcher -- Connecting to remote host");

                _host = host;
                _port = port;
                _connectCallback = callback;
                _responseFilter = filter;
                _factory.BeginConnect( host, port, HandleConnect );
            }
        }
Beispiel #2
0
        public HttpServer( INetworkConnection connection, IHttpResponseFilter responseFilter )
        {
            Contract.Requires( connection != null );

            _responseFilter = responseFilter;
            _connection = connection;

            connection.ConnectionClosed += ConnectionConnectionClosed;
            connection.Shutdown += ConnectionConnectionClosed;
            connection.DataAvailable += ConnectionDataAvailable;

            _parser = new HttpStreamParser();
            _parser.ReadResponseHeaderComplete += ParserReadResponseHeaderComplete;
        }
 public void ConnectToServer(string host, int port, IHttpResponseFilter filter, Action<bool> callback)
 {
     Contract.Requires(!string.IsNullOrEmpty(host));
     Contract.Requires(port > 0);
     Contract.Requires(callback != null);
 }