boolean removed = listeners.remove(listener);
if (!keepOnDisconnect) {
if (removed && keepAliveJobName == null) {
if (ScopeUtils.isRoom(this) && listeners.isEmpty()) {
// create job to kill the scope off if no listeners join within the delay
ISchedulingService schedulingService = (ISchedulingService) parent.getContext().getBean(ISchedulingService.BEAN_NAME);
// by default keep a scope around for a fraction of a second
keepAliveJobName = schedulingService.addScheduledOnceJob((keepDelay > 0 ? keepDelay * 1000 : 100), new KeepAliveJob(this));
}
}
} else {
log.trace("Scope: {} is exempt from removal when empty", getName());
}