switch(phase)
{
case ItsNatAttachedClientEvent.REQUEST:
if (event instanceof ItsNatAttachedClientTimerEvent)
{
ItsNatAttachedClientTimerEvent timerEvent = (ItsNatAttachedClientTimerEvent)event;
boolean accepted = (timerEvent.getRefreshInterval() >= 1000);
if (!accepted)
{
try
{
Writer out = response.getWriter();
out.write("<html><body><h1>Remote control request rejected. Interval too short: ");
out.write(Integer.toString(timerEvent.getRefreshInterval()));
out.write("</h1></body></html>");
}
catch(IOException ex) { throw new RuntimeException(ex); }
}
event.setAccepted(accepted);
}
else if (event instanceof ItsNatAttachedClientCometEvent)
{
event.setAccepted(true); // Nothing to check
}
else // "None" refresh mode
{
event.setAccepted(true); // Nothing to check
}
if (event.getWaitDocTimeout() > 30000) // Demasiado tiempo de espera
event.setAccepted(false);
if (!event.isAccepted())
return;
break;
case ItsNatAttachedClientEvent.LOAD:
//event.setAccepted(false);
break;
case ItsNatAttachedClientEvent.REFRESH:
if (itsNatDoc.isInvalid())
{
observer.addCodeToSend("alert('Observed document was destroyed');");
}
else if (event instanceof ItsNatAttachedClientTimerEvent)
{
// Esto no es lo normal (modificar a trav�s de un visor el documento)
// pero es para probar.
// Lo normal es a partir del estado del DOM hacer algo en consecuencia
// junto con la sessi�n del "observado" que tenemos acceso a ella via ItsNatDocument
ItsNatAttachedClientTimerEvent timerEvent = (ItsNatAttachedClientTimerEvent)event;
long initTime = timerEvent.getItsNatServletRequest().getClientDocument().getCreationTime();
long currentTime = System.currentTimeMillis();
int limitMilisec = 15*60*1000; // 15 minutos, para evitar que est� indefinidamente
if (currentTime - initTime > limitMilisec)
{
event.setAccepted(false);