Package net.officefloor.server
Interface RequestHandler<R>
public interface RequestHandler<R>
Handles requests.
- Author:
- Daniel Sagenschneider
-
Method Summary
Modifier and TypeMethodDescriptionvoidcloseConnection(Throwable exception) Allows to close connection.voidexecute(SocketRunnable runnable) Obtains theStreamBufferPoolfor thsiRequestHandler.voidhandleRequest(R request) Handles a request.booleanIndicates if readingSocketinput from client.voidsendImmediateData(StreamBuffer<ByteBuffer> immediateHead) Sends data immediately.
-
Method Details
-
isReadingInput
boolean isReadingInput()Indicates if reading
Socketinput from client.To avoid out of memory, the reading from the
Socketmay be halted temporarily. This indicates if actively reading input from theSocket.- Returns:
trueif readingSocketinput from client.
-
getStreamBufferPool
StreamBufferPool<ByteBuffer> getStreamBufferPool()Obtains theStreamBufferPoolfor thsiRequestHandler.- Returns:
StreamBufferPoolfor thsiRequestHandler.
-
execute
- Parameters:
runnable-SocketRunnable.
-
handleRequest
- Parameters:
request- Request.- Throws:
IOException- If fails to handle the request.IllegalStateException- If invoked from anotherThread.
-
sendImmediateData
- Parameters:
immediateHead- HeadStreamBufferto linked list ofStreamBufferinstances of data to send immediately.- Throws:
IllegalStateException- If invoked from anotherThread.
-
closeConnection
Allows to close connection.- Parameters:
exception- OptionalExceptionfor the cause of closing the connection.nullto indicate normal close.
-