How can I do long-polling using netty framework? Say for example I fetch http://localhost/waitforx
but waitforx
is asynchronous because it has
You could write a response header first, and then send the body (content) later from other thread.
void messageReceived(...) {
HttpResponse res = new DefaultHttpResponse(...);
res.setHeader(...);
...
channel.write(res);
}
// In a different thread..
ChannelBuffer partialContent = ...;
channel.write(partialContent);
You could also do the following in [sfnrpc]: http://code.google.com/p/sfnrpc
Object object = RPCClient.getInstance().invoke("#URN1","127.0.0.1:6878","echo",true,60,"", objArr,classArr, sl);
The true causes communication to be synchronous.
You can use netty-socketio project. It's implementation of Socket.IO server with long polling support. On web side you can use Socket.IO client javascript lib.