xmlBlaster 2.2.0 API

org.xmlBlaster.protocol.http
Class HttpPushHandler.HttpPingThread

java.lang.Object
  extended by java.lang.Thread
      extended by org.xmlBlaster.protocol.http.HttpPushHandler.HttpPingThread
All Implemented Interfaces:
java.lang.Runnable
Enclosing class:
HttpPushHandler

private class HttpPushHandler.HttpPingThread
extends java.lang.Thread

Ping the browser, to avoid that the web server or the browser closes the http connection after a vendor specific timeout.

Note that the ping sends some bytes as well, the netscape browser for example closes the http connection if the amount of bytes per second falls below a certain level.

The browser responses with 'pong' which allows us to check if the browser is still here.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private  long counter
           
private  long PING_INTERVAL
           
private  boolean pingRunning
           
private  HttpPushHandler pushHandler
           
private  int waitForPong
          We wait for a browser response (pong) after out ping
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
HttpPushHandler.HttpPingThread(HttpPushHandler pushHandler, long pingInterval, java.lang.String loginName)
           
 
Method Summary
 void pong()
          Response from the browser on our ping.
 void run()
           
 void stopThread()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

pushHandler

private HttpPushHandler pushHandler

PING_INTERVAL

private final long PING_INTERVAL

pingRunning

private boolean pingRunning

waitForPong

private int waitForPong
We wait for a browser response (pong) after out ping


counter

private long counter
Constructor Detail

HttpPushHandler.HttpPingThread

HttpPushHandler.HttpPingThread(HttpPushHandler pushHandler,
                               long pingInterval,
                               java.lang.String loginName)
Parameters:
pingInterval - How many milli seconds sleeping between the pings
loginName - For debugging only
Method Detail

pong

public void pong()
Response from the browser on our ping.

Sometimes the browser is fine but suddenly a pong is missing, for example ... "refresh-2084", "refresh-2086", ...
Number 2085 was just missing in the logs.
So we reset the waitForPong counter, and accept a sometimes missing pong.


stopThread

public void stopThread()

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.