1 Reply Latest reply on Aug 13, 2008 9:00 AM by rmaucher

    CometEvent WRITE/resume() interface

      Hi
      I'm a bit baffled with the WRITE semantic in CometEvent.
      Does the resume() semantic imply that the servlet should keep a reference to the last comet event handled and call resume on it ?
      I.e, in pseudo-code:

      void event(CometEvent e) {
      ...
      case READ:
      if (all request is read) {
      e.suspend();
      doAsync(e);
      }
      case EVENT:
      // resume was called: write on reponse
      while (e.ready()) {
      e.getHttpResponse().getWriter().print(some buffer);
      }
      case WRITE:
      // Continue with writing
      e.getHttpResponse().getWriter().print(some other buffer);
      }

      void doAsync(final CometEvent e) {
      (new Thread() { public void run() {
      ...do something...
      e.resume();
      }}.start();
      }

      Anyone can confirm ?

      /zog

        • 1. Re: CometEvent WRITE/resume() interface
          rmaucher

          Yes, as with the other operations you need to keep the object around (to be honest, suspend/resume would be better on request or response, but adding to the Servlet API classes is not very convinient - in the future, the servlet 3.0 API may well have methods which could mean something to the Comet API).