com.echomine.jabber
Class KeepAlive

java.lang.Object
  extended by java.lang.Thread
      extended by com.echomine.jabber.KeepAlive
All Implemented Interfaces:
java.lang.Runnable

public class KeepAlive
extends java.lang.Thread

The class will run in the background as a thread that periodically "pings" the socket to make sure that the connection is not stale. If the connection is stale, then the session will be disconnected. This solves the problem where you have no idea when you were disconnected from the server and your client still think that it is.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
KeepAlive(JabberSession session, int timeout)
          Creates a keepalive thread that does NOT run as a daemon thread.
KeepAlive(JabberSession session, int timeout, boolean isDaemon)
           
 
Method Summary
 void run()
           
 void shutdown()
           
 
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
 

Constructor Detail

KeepAlive

public KeepAlive(JabberSession session,
                 int timeout)
Creates a keepalive thread that does NOT run as a daemon thread.

Parameters:
session - the session that you want to do keep alive pings
timeout - time interval between pings. Must be > 0

KeepAlive

public KeepAlive(JabberSession session,
                 int timeout,
                 boolean isDaemon)
Parameters:
session - the session that you want to do keep alive pings
timeout - time interval between pings. Must be > 0
isDaemon - daemon thread?
Method Detail

shutdown

public void shutdown()

run

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


Copyright © 2001-2005 Echomine. All Rights Reserved.