|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.zkoss.zkex.ui.comet.CometServerPush
public class CometServerPush
A server-push implementation that is based on comet.
This implementation is compatible with any version of Servlet. It also means
it doesn't utilize Servlet 3 asynchronous processing support.
If you are using Servlet 3 servers, it is recommended to use
org.zkoss.zkmax.ui.comet.CometServerPush
instead.
Available in ZK PE.
Nested Class Summary | |
---|---|
static interface |
CometServerPush.AsyncInfo
The interface for implementing asynchronous processing. |
Constructor Summary | |
---|---|
CometServerPush()
|
Method Summary | ||
---|---|---|
boolean |
activate(long timeout)
|
|
boolean |
deactivate(boolean stop)
|
|
org.zkoss.zk.ui.Desktop |
getDesktop()
Returns the desktop that this server push belongs to (never null). |
|
protected String |
getStartScript()
Returns the JavaScript codes to enable (aka., start) the server push. |
|
protected String |
getStopScript()
Returns the JavaScript codes to disable (aka., stop) the server push. |
|
boolean |
isActive()
|
|
void |
onPiggyback()
|
|
protected void |
onStart()
Called when start(org.zkoss.zk.ui.Desktop) is called. |
|
protected void |
onStop()
Called when stop() is called. |
|
protected void |
processRequest(org.zkoss.zk.ui.Execution exec,
CometServerPush.AsyncInfo ai)
Called when receiving the comet request from the client. |
|
|
schedule(org.zkoss.zk.ui.event.EventListener<T> listener,
T event,
org.zkoss.zk.ui.sys.Scheduler<T> scheduler)
|
|
protected boolean |
setBusy()
Sets busy and return if it is busy for processing other request. |
|
void |
start(org.zkoss.zk.ui.Desktop desktop)
Starts the server push. |
|
protected void |
startClientPush()
Sends an AU response to the client to start the server push. |
|
void |
stop()
Stops the server push. |
|
protected void |
stopClientPush()
Sends an AU response the client to stop the server push. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CometServerPush()
Method Detail |
---|
protected void startClientPush()
start(org.zkoss.zk.ui.Desktop)
.
The derived class usually overrides this method to support different devices.
The default implementation is to send an AuScript
response to contain
the script specified in a preference called CometServerPush.start
,
or the script returned by getStartScript()
, if the preference is not found.
Devices that don't support scripts could override this method
to send a custom AU response (AuResponse
).
protected void stopClientPush()
The derived class usually overrides this method to support different devices, such as ZK Mobile.
The default implementation is to send an AuScript
instance to contain
the script specified in a preference called CometServerPush.stop
,'
or the script returned by getStopScript()
, if the preference is not found.
Devices that don't support scripts could override this method
to send a custom AU response (AuResponse
).
protected String getStartScript()
startClientPush()
to prepare the script
of AuScript
that will be sent to the client.
protected String getStopScript()
stopClientPush()
to prepare the script
of AuScript
that will be sent to the client.
public org.zkoss.zk.ui.Desktop getDesktop()
public boolean isActive()
isActive
in interface org.zkoss.zk.ui.sys.ServerPush
public void start(org.zkoss.zk.ui.Desktop desktop)
The derived class rarely need to override this method.
Rather, override startClientPush()
.
start
in interface org.zkoss.zk.ui.sys.ServerPush
public void stop()
The derived class rarely need to override this method.
Rather, override stopClientPush()
.
stop
in interface org.zkoss.zk.ui.sys.ServerPush
protected void onStart()
start(org.zkoss.zk.ui.Desktop)
is called.
This method is called before startClientPush()
, and used to initialize the desktop,
if necessary.
The default implementation initializes an extension to process the comet request.
protected void onStop()
stop()
is called.
This method is called after stopClientPush()
is called and this server push
has been cleaned up.
The default implementaiton does nothing.
public void onPiggyback()
onPiggyback
in interface org.zkoss.zk.ui.sys.ServerPush
public <T extends org.zkoss.zk.ui.event.Event> void schedule(org.zkoss.zk.ui.event.EventListener<T> listener, T event, org.zkoss.zk.ui.sys.Scheduler<T> scheduler)
schedule
in interface org.zkoss.zk.ui.sys.ServerPush
protected boolean setBusy()
It is possible since the client might abort the previous one and issue a new one but ther server didn't know.
protected void processRequest(org.zkoss.zk.ui.Execution exec, CometServerPush.AsyncInfo ai) throws IOException
IOException
public boolean activate(long timeout) throws InterruptedException, org.zkoss.zk.ui.DesktopUnavailableException
activate
in interface org.zkoss.zk.ui.sys.ServerPush
InterruptedException
org.zkoss.zk.ui.DesktopUnavailableException
public boolean deactivate(boolean stop)
deactivate
in interface org.zkoss.zk.ui.sys.ServerPush
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |