org.xsocket.stream
Interface ITimeoutHandler

Package class diagram package ITimeoutHandler
All Superinterfaces:
IHandler
All Known Implementing Classes:
HandlerChain

public interface ITimeoutHandler
extends IHandler

Handles timeout. The timeouts will be defined by the server. To modify the timeouts the proper server methods has to be called. E.g.

    ...
    IMultithreadedServer server = new MultithreadedServer(new MyHandler());
    server.setIdleTimeoutSec(60);
    StreamUtils.start(server);
    ...
    
    
    class MyHandler implements ITimeoutHandler {
    
        public boolean onConnectionTimeout(INonBlockingConnection connection) throws IOException {
           ...
           connection.close();
           return true; // true -> event has been handled
        }
        
        public boolean onIdleTimeout(INonBlockingConnection connection) throws IOException {
           ...
           connection.close();
           return true;  // true -> event has been handled
        }
    }
 


Method Summary
 boolean onConnectionTimeout(INonBlockingConnection connection)
          handles the connection timeout.
 boolean onIdleTimeout(INonBlockingConnection connection)
          handles the idle timeout.
 

Method Detail

onIdleTimeout

boolean onIdleTimeout(INonBlockingConnection connection)
                      throws java.io.IOException
handles the idle timeout.

Parameters:
connection - the underlying connection
Returns:
true if the timeout event has been handled (in case of false the connection will be closed by the server)
Throws:
java.io.IOException - if an error occurs. Throwing this exception causes that the underlying connection will be closed.

onConnectionTimeout

boolean onConnectionTimeout(INonBlockingConnection connection)
                            throws java.io.IOException
handles the connection timeout.

Parameters:
connection - the underlying connection
Returns:
true if the timeout event has been handled (in case of false the connection will be closed by the server)
Throws:
java.io.IOException - if an error occurs. Throwing this exception causes that the underlying connection will be closed.