public interface AsyncHandle
A class to handle the request and response handling when using asynchronous request handling.
To asynchronously read the request body, see setReadListener(RequestBodyListener)
. To
write data, this interface provides asynchronous write operations, or alternatively you can use the
blocking write operations on the original MuResponse
.
Modifier and Type | Interface and Description |
---|---|
static interface |
AsyncHandle.ResponseCompletedListener |
Modifier and Type | Method and Description |
---|---|
void |
complete()
Call this to indicate that the response is complete.
|
void |
complete(Throwable throwable)
Calling this will mark the request as complete and log the error message.
|
void |
setReadListener(RequestBodyListener readListener)
Sets a listener that will be notified when chunks of request data become available.
|
void |
setResponseCompletedHandler(AsyncHandle.ResponseCompletedListener responseCompletedListener)
Add a listener for when request processing is complete.
|
Future<Void> |
write(ByteBuffer data)
Writes data to the response asynchronously.
|
void |
write(ByteBuffer data,
WriteCallback callback)
Writes data to the response asynchronously.
|
void setReadListener(RequestBodyListener readListener)
Sets a listener that will be notified when chunks of request data become available.
If this is not set, then the usual (blocking) request reading methods on the request object can be used.
readListener
- The listener.void complete()
void complete(Throwable throwable)
throwable
- an exception to logvoid write(ByteBuffer data, WriteCallback callback)
Writes data to the response asynchronously.
Note that even in async mode it is possible to use the blocking write methods on the MuResponse
See write(ByteBuffer)
for an alternative that returns a future.
data
- The data to writecallback
- The callback when the write succeeds or failsFuture<Void> write(ByteBuffer data)
Writes data to the response asynchronously.
Note that even in async mode it is possible to use the blocking write methods on the MuResponse
See write(ByteBuffer, WriteCallback)
for an alternative that uses a callback.
data
- The data to writevoid setResponseCompletedHandler(AsyncHandle.ResponseCompletedListener responseCompletedListener)
responseCompletedListener
- The handler to invoke when the request is complete.Copyright © 2017–2019. All rights reserved.