Hi,
I just pushed a request filter (we had one in mina 2 but with no doco
and weird code).
The idea is simple, on some protocols ( like CoAP and at some extend
HTTP) you push a response and could receive a async response.
This filter produce a IoFuture for waiting/listening the response to
your request.
The idea is to async chain request like that :
IoFuture<Response> future = rq.request(session, message, 10000);
response.register(new AbstractIoFutureListener<Response>() {
public void completed(Response result) {
rq.request(session, another..);
// chain another handler
}
});
This avoid the need to coding state machine when the behaviour is not
too complex.
For guessing which message is the response to which query the messages
should provide a ".requestId()" method providing an identifier (in
coap it's a short integer).
I'm using it for CoAP, so an example will be provided.
The code is here :
https://git-wip-us.apache.org/repos/asf?p=mina.git;a=tree;f=core/src/main/java/org/apache/mina/filter/query;h=bd55a9d5d9d7f19b3418f6bb8bc3416dbd399655;hb=a68de05cc12a20c2c6208cb33c0ac81b6f24325e
Feedback Welcome :)
--
Julien Vermillard :::: http://people.apache.org/~jvermillard/
|