org.directwebremoting.extend
Interface Sleeper

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
BaseSleeper, JettyContinuationSleeper, Servlet30Sleeper, ThreadWaitSleeper

public interface Sleeper
extends java.io.Serializable

A Sleeper allows the request to halt and cease execution for some time, while still allowing output.

All implementations of Sleeper must be Serializable so we can store Sleepers in the session and therefore have other connections wake them up.

Author:
Joe Walker [joe at getahead dot ltd dot uk], Mike Wilson

Method Summary
 void enterSleep(java.lang.String batchId, java.lang.Runnable onClose, int disconnectedTime)
          'halt' the current execution in some way.
 void wakeUpForData()
          Wake up to handle new data that arrived in the associated ScriptSession.
 int wakeUpToClose()
          Wake up to close down the Sleeper and free any resources held by it.
 

Method Detail

enterSleep

void enterSleep(java.lang.String batchId,
                java.lang.Runnable onClose,
                int disconnectedTime)
                throws java.io.IOException
'halt' the current execution in some way. This method should be the last meaningful thing that is done in a poll request to activate the Sleeper's background wait mechanism.

Parameters:
batchId - The batchId for the poll
onClose - The action to take when wakeUpToClose() is called
disconnectedTime - The waiting time to instruct the browser before the next poll
Throws:
java.io.IOException

wakeUpForData

void wakeUpForData()
Wake up to handle new data that arrived in the associated ScriptSession.


wakeUpToClose

int wakeUpToClose()
Wake up to close down the Sleeper and free any resources held by it. The previously supplied onClose callback will be executed.

Returns:
the disconnectedTime that will be sent to the client

Copyright ยจ 2008