public class WebSocketServerPush extends java.lang.Object implements ServerPush
WebSocketWebAppInit for more information.| Constructor and Description |
|---|
WebSocketServerPush() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
activate(long timeout)
Activate the current thread (which must be a server-push thread).
|
boolean |
deactivate(boolean stop)
Deactivates the current thread (which must be a server-push thread).
|
boolean |
isActive()
Returns if the working thread of the server push is active.
|
void |
onPiggyback()
Called when
Events.ON_PIGGYBACK
is received. |
void |
resume()
Resumes server-push - this is required after desktop recycling.
|
<T extends Event> |
schedule(EventListener<T> listener,
T event,
Scheduler<T> scheduler)
Called by the associated desktop to schedule a task to execute
asynchronously.
|
void |
setReady(boolean ready) |
protected void |
setWebSocketConnectionInfos(WebSocketEndPoint webSocketEndpoint,
javax.servlet.http.HttpServletRequest request) |
void |
start(Desktop desktop)
Starts and initializes the server-push controller.
|
void |
stop()
Stops and cleans up the server-push controller.
|
protected void |
wakePending() |
public void setReady(boolean ready)
protected void setWebSocketConnectionInfos(WebSocketEndPoint webSocketEndpoint, javax.servlet.http.HttpServletRequest request)
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 ServerPushpublic void resume()
ServerPushServerPush.resume() is called when UiEngine.recycleDesktop(org.zkoss.zk.ui.Execution, org.zkoss.zk.ui.Page, java.io.Writer)
is called to resume a previously enabled server-push on the recycled
desktop.
resume in interface ServerPushpublic <T extends Event> void schedule(EventListener<T> listener, T event, Scheduler<T> scheduler)
ServerPushThe implementation usually delegates the scheduling to the scheduler passed as the third argument, which is controlled by the desktop. Of course, it could schedule it by itself.
schedule in interface ServerPushlistener - the task to executeevent - the event to be passed to the task (i.e., the event listener).
It could null or any instance as long as the task recognizes it.scheduler - the default scheduler to schedule the task.
The implementation usually delegates the scheduling back to it.
If you prefer to handle it by yourself, you could ignore it.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.
Ignored (i.e., never timeout) if non-positive.java.lang.InterruptedException - if it is interrupted by other threadDesktopUnavailableException - if the desktop is removed
(when activating).public boolean deactivate(boolean stop)
ServerPushdeactivate in interface ServerPushstop - whether to stop after deactivateServerPush.activate(long)protected void wakePending()
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 ServerPushCopyright © 2005-2011 Potix Corporation. All Rights Reserved.