// CLIENT
public void comet() {
cometService.comet(new AsyncCallback() {
public void onFailure(Throwable caught) {
}
public void onSuccess(Object result) {
Message msg = (Message) result;
cometService.comet(this);
....
}
});
}
// SERVER
class GWTCometHandler implements CometHandler<HttpServletResponse> {
HttpServletResponse res;
HttpServletRequest req;
public void onEvent(CometEvent ce) throws IOException{
System.out.println("onEvent");
Message msg = (Message) ce.attachment();
try {
String encoded =
RPC.encodeResponseForSuccess(CometServiceImpl.class.getMethod("comet"),
msg);
System.out.println("encoded=" + encoded);
PrintWriter writer = res.getWriter();
writer.write(encoded);
writer.flush();
cc.resumeCometHandler(this);
}
catch (SecurityException e) {
System.out.println("onEvent:e=" + e);
e.printStackTrace();
}
catch (SerializationException e) {
System.out.println("onEvent:e=" + e);
e.printStackTrace();
}
catch (NoSuchMethodException e) {
System.out.println("onEvent:e=" + e);
e.printStackTrace();
}
}
..........
Hi,
(I'm using GlassfishV2). I call the onEvent method using comet.notify(msg,
CometEvent.NOTIFY)
Using this code my application works fine: when I receve a notification, I
resume the connection (using cc.resumeCometHandler(this)), the GWT-RPC call
can receive its Message and then I have to recall cometService.comet(this)
in order to receive next Message. But this is the long poll mode, that's
right?
But I've got a very fast notifier and using the poll mode the client lost
some notifications between the resume connection and the new connection...
For this reason I'd like to use the streaming mode. How can I developing it
using GWT-RPC?
Thanks
Marco
--
View this message in context: http://www.nabble.com/GWT-%2B-Comet-question-%28was-Re%3A--Jean-Francois-Arcand%27s-Blog--New-Comment-Posted-to-%27Building-GWT-Comet-based-web-app-using-Grizzly-Comet%27-tp21416392p21578011.html
Sent from the Grizzly - Users mailing list archive at Nabble.com.