org.xsocket.connection
Interface IIdleTimeoutHandler
- All Superinterfaces:
- IHandler
- All Known Implementing Classes:
- HandlerChain
public interface IIdleTimeoutHandler
- extends IHandler
Handles idle timeout. The timeouts will be defined by the server. To modify the timeouts
the proper server methods has to be called. E.g.
...
IServer server = new Server(new MyHandler());
server.setIdleTimeoutMillis(60 * 1000);
ConnectionUtils.start(server);
...
class MyHandler implements IIdleTimeoutHandler {
public boolean onIdleTimeout(INonBlockingConnection connection) throws IOException {
...
connection.close();
return true; // true -> event has been handled (by returning false xSocket will close the connection)
}
}
onIdleTimeout
boolean onIdleTimeout(INonBlockingConnection connection)
throws 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:
IOException - if an error occurs. Throwing this exception causes that the underlying connection will be closed.