org.xlightweb
Interface IHttpConnectHandler

Package class diagram package IHttpConnectHandler
All Superinterfaces:
IHttpConnectionHandler

public interface IHttpConnectHandler
extends IHttpConnectionHandler

The connect handler will be called if a new http connection has been established. Example:

  class MyHandler implements IRequestHandler, IHttpConnectHandler {
  
     private String host = null;
     private int port = 0;
     
     public ProxyHandlerHandler(String host, int port) {
        this.host = host;
        this.port = port;
     }
     
     public boolean onConnect(IHttpConnection httpConnection) throws IOException {
     
        // create the forward connection and set some properties
        HttpClientConnection forwardConnection = new HttpClientConnection(host, port, new DisconnectHandler());
        forwardConnection.setIdleTimeoutSec(IDLE_TIMEOUT_SEC);
        
        // cross attaching (required for disconnecting)
        httpConnection.setAttachment(forwardConnection);
        forwardConnection.setAttachment(httpConnection);
     }


     public void onRequest(HttpServerConnection httpServerConnection) throws IOException {
        
        ...
        
     }                  
  }        
 


Method Summary
 boolean onConnect(IHttpConnection httpConnection)
          see IConnectHandler
 

Method Detail

onConnect

boolean onConnect(IHttpConnection httpConnection)
                  throws IOException
see IConnectHandler

Throws:
IOException