public boolean handleWatchEvent(WatcherElement watcher, Lock lock)
{
boolean isWatchEnable = watcher.isWatchEnabled();
+ if (lock== null)//no update on the list
+ return isWatchEnable;
if (client != null)
{
* @return true to enable watcher, or false to disable it in future WatcherThread cycles.
*/
public boolean handleWatchEvent(WatcherElement watcher, Lock lock)
- {
- // boolean isWatchEnable = watcher.isWatchEnabled();
- if (client != null)
+ {
+ // if lock is null, no client has been added since last, clear.
+ //the client is then the last client
+ if (client != null && lock == null)
{
//checks if the client is not already in the lists
- ClientHandle[] cl = clist.retrieveClientList(lock);//clist.retrieveClientList();
+ // ClientHandle[] cl = clist.retrieveClientList();//lock);//clist.retrieveClientList();
// ask to the client to cpoy application data into the document
client.evgen._raise(Events.DOCUMENT_FINALIZEAPPDATA, null, client,null);
- if(cl == null || cl.length<1 )
- {//no client has registered as active
+ // if(cl == null || cl.length<1 )
+ // {//no client has registered as active
//the client is the last one, so close current session
log.info("last client removed: closing session");
getSessionManager().removeSession(client.getSessionHandle());
log.debug("Session removed");
- }
- else
- {
+ }
+ else
+ {
log.debug("not the last client found ");
// ask to the client to cpoy application data into the document
// client.evgen._raise(Events.DOCUMENT_FINALIZEAPPDATA, null, client,null);
- }
- // watcher.haltWatch();
- log.debug("Stopping EventGenerator..");
- client.evgen.stopWatching();
-
-
- }
+ // / }
+ log.debug("Stopping EventGenerator..");
+ client.evgen.stopWatching();
+ }
watcher.setHandler(null);//Do not check if the client is the last client. watcher will shutdown anyway
return false;