Salut,
marcoflower wrote:
> // 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");
Make sure your synchronize the onEvent (just to reduce out of order
messages).
>
> 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?
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?
Just never call resumeCometHandler. That will means the connection will
stay suspended (streaming mode) forever.
Does it help?
A+
--Jeanfrancois
>
> Thanks
>
> Marco