01: package example;
02:
03: import com.caucho.servlet.comet.*;
04:
05: public class CometState {
06: private final CometController _controller;
07:
08: private int _count;
09:
10: public CometState(CometController controller) {
11: _controller = controller;
12: }
13:
14: public boolean isClosed() {
15: return _controller.isClosed();
16: }
17:
18: public boolean wake() {
19: _controller.setAttribute("comet.count", ++_count);
20:
21: if (_count <= 10) {
22: _controller.wake();
23:
24: return !_controller.isClosed();
25: } else {
26: _controller.close();
27:
28: return false;
29: }
30: }
31: }
|