>
Hello!
tnx for you help, but i still need some assistance to figure why this
piece of stupid code doesn't work as i suppose :D
I can see the output ("RESUME" and "START") but i don't get any reply
(ie rama stupid)
basically, this is more or less what i have think that i will need to
add to my application.
when a request is a push over pull req, i add the res to session, and
wait until someone add to msg queue something.
if someone add something to msg queue, res is resumed, and queue
flushed out.
What i don't probably understand is why the request isn't executed.
Notice that if i put a thread.sleep at the end of service function,
request is executed.
But, in such a way, i will not block other request to be executed?
public class Webserver {
public static void main(String[] args) {
try {
GrizzlyWebServer ws = new GrizzlyWebServer();
ws.addGrizzlyAdapter(new GrizzlyAdapter() {
public void service(GrizzlyRequest req, final GrizzlyResponse
res) {
FakeSession s = FakeSession.fake;
s.res = res;
s.start();
res.suspend(1000, this, new CompletionHandler<GrizzlyAdapter>
() {
public void cancelled(GrizzlyAdapter arg0) {
}
public void resumed(GrizzlyAdapter arg0) {
System.out.println("RESUME");
try {
res.getWriter().println("rama stupid");
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
}, new String[]{});
ws.start();
} catch (IOException ex){
// Something when wrong.
}
}
static class FakeSession extends Thread {
protected GrizzlyResponse res;
private static FakeSession fake = new FakeSession();
public void run() {
try {
System.out.println("START");
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
res.resume();
}
}
}
> Take a look at:
>
> http://www.nabble.com/-ANN--New-HTTP-API-for-Resuming-Suspending-
> Request-Response-tc20573149.html#a20573149