|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.zkoss.zkex.ui.impl.PollingServerPush
public class PollingServerPush
A server-push implementation that is based on client-polling.
| Constructor Summary | |
|---|---|
PollingServerPush()
|
|
| Method Summary | |
|---|---|
boolean |
activate(long timeout)
Activate the current thread (which must be a server-push thread). |
boolean |
deactivate(boolean stop)
Deactvates the current thread (which must be a server-push thread). |
protected java.lang.String |
getStartScript()
Returns the JavaScript codes to enable (aka., start) the server push. |
protected java.lang.String |
getStopScript()
Returns the JavaScript codes to disable (aka., stop) the server push. |
boolean |
isActive()
Returns if the working thread of the server push is active. |
void |
onPiggyback()
Called when Events.ON_PIGGYBACK
is received. |
void |
setDelay(int min,
int max,
int factor)
Sets the delay between each polling request. |
void |
start(Desktop desktop)
Stats and initializes the server-push controller. |
protected void |
startClientPush()
Sends an AU response to the client to start the server push. |
void |
stop()
Stops and cleans up the server-push controller. |
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 PollingServerPush()
| Method Detail |
|---|
protected void startClientPush()
start(org.zkoss.zk.ui.Desktop).
The derived class usually overrides this method to support different devices, such as ZK Mobile.
The default implementation is to send AuScript containing
the script returned by getStartScript().
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 AuScript containing
the script returned by getStopScript().
Devices that don't support scripts could override this method
to send a custom AU response (AuResponse).
protected java.lang.String getStartScript()
startClientPush() to prepare the script
of AuScript that will be sent to the client.
protected java.lang.String getStopScript()
stopClientPush() to prepare the script
of AuScript that will be sent to the client.
public boolean isActive()
ServerPushExecutions.activate(org.zkoss.zk.ui.Desktop) and
Executions.deactivate(org.zkoss.zk.ui.Desktop).
isActive in interface ServerPushpublic void start(Desktop desktop)
ServerPushServerPush.start(org.zkoss.zk.ui.Desktop) is called when Desktop.enableServerPush(boolean)
is called to enable the server-push feature for the specified
desktop.
start in interface ServerPushpublic void stop()
ServerPushServerPush.stop() is called when Desktop.enableServerPush(boolean)
is called to disable the server-push feature, or when the desktop
is being removed.
stop in interface ServerPush
public void setDelay(int min,
int max,
int factor)
Default: use the preference called
PollingServerPush.delay.min
PollingServerPush.delay.max,
and PollingServerPush.delay.factor.
If not defined, min is 1000, max is 15000, and factor is 5.
setDelay in interface ServerPushmin - the minimal delay to poll the server for any pending
server-push threads.
Ignore (aka., the default value is used) if non-positive.
Unit: milliseconds.max - the maximal delay to poll the server for any pending
server-push threads.
Ignore (aka., the default value is used) if non-positive.
Unit: milliseconds.factor - the delay factor. The real delay is the processing
time multiplies the delay factor. For example, if the last request
took 1 second to process, then the client polling will be delayed
for 1 x factor seconds, unless it is value
Ignore (aka., the default value is used) if non-positive.public void onPiggyback()
ServerPushEvents.ON_PIGGYBACK
is received. The invocation is passive (i.e., triggered by
other events, rather than spontaneous).
This method is called in
the context of an event listener. In other words, the execution
is activated and you can retrieve it by
Executions.getCurrent().
onPiggyback in interface ServerPush
public boolean activate(long timeout)
throws java.lang.InterruptedException,
DesktopUnavailableException
ServerPushThe invoker of this method must invoke ServerPush.deactivate(boolean)
in this finally clause.
Note: the activation is applied to the desktop that was
assigned by ServerPush.start(org.zkoss.zk.ui.Desktop).
Unlike ServerPush.onPiggyback(),
this method is NOT called in the context of an event listener.
Rather, it is called in the thread of a server-push thread.
activate in interface ServerPushtimeout - the maximum time to wait in milliseconds.
Ingored (i.e., never timeout) if non-positive.
java.lang.InterruptedException - if it is interrupted by other thread
DesktopUnavailableException - if the desktop is removed
(when activating).public boolean deactivate(boolean stop)
ServerPush
deactivate in interface ServerPushstop - whether to stop after deactivate
ServerPush.activate(long)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||