soc.server.genericServer
Class Server.ConnExcepDelayedPrintTask

java.lang.Object
  extended by java.util.TimerTask
      extended by soc.server.genericServer.Server.ConnExcepDelayedPrintTask
All Implemented Interfaces:
java.lang.Runnable
Enclosing class:
Server

protected class Server.ConnExcepDelayedPrintTask
extends java.util.TimerTask

This object represents one client-connect or disconnect debug-print announcement within Server.cliConnDisconPrintsPending. When a client is removed due to an error, the error message print is delayed briefly, in case the client is doing a disconnect/reconnect (as some robot clients do). This gives the server a chance to suppress the 2 left/rejoined messages if the client quickly reconnects.

It's up to the server application (extending this generic Server) to recognize that the arrived client is the same as the departed one, and remove both messages from the pending vector. This is typically done via the client's username or nickname, as stored in StringConnection.getData().

Since:
1.1.07
Author:
Jeremy D Monin <jeremy@nand.net>
See Also:
Server.addConnection(StringConnection)., Server.CLI_DISCON_PRINT_TIMER_FIRE_MS

Field Summary
 StringConnection arrivingConn
          Key for Server.cliConnDisconPrintsPending; null unless isArriveNotDepart
 java.lang.Object connData
          Key for Server.cliConnDisconPrintsPending; non-null unless isArriveNotDepart; if so, connection name from StringConnection.getData()
 java.lang.String connHost
           
 java.lang.Throwable excep
          may be null
 boolean isArriveNotDepart
          Arrival, not a departure
 long thrownAt
          Time at which this message was constructed, via System.currentTimeMillis()
 
Constructor Summary
Server.ConnExcepDelayedPrintTask(boolean isArrival, java.lang.Throwable ex, StringConnection c)
          Create a new delayed print.
 
Method Summary
 void run()
          Debug-print connection's arrival or departure, and remove from pending list.
 
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

excep

public java.lang.Throwable excep
may be null


connData

public java.lang.Object connData
Key for Server.cliConnDisconPrintsPending; non-null unless isArriveNotDepart; if so, connection name from StringConnection.getData()


connHost

public java.lang.String connHost
See Also:
StringConnection.host()

isArriveNotDepart

public boolean isArriveNotDepart
Arrival, not a departure


arrivingConn

public StringConnection arrivingConn
Key for Server.cliConnDisconPrintsPending; null unless isArriveNotDepart


thrownAt

public long thrownAt
Time at which this message was constructed, via System.currentTimeMillis()

Constructor Detail

Server.ConnExcepDelayedPrintTask

public Server.ConnExcepDelayedPrintTask(boolean isArrival,
                                        java.lang.Throwable ex,
                                        StringConnection c)
                                 throws java.lang.IllegalArgumentException
Create a new delayed print. See class javadoc for details. If debug isn't enabled, will not do anything useful.

Parameters:
isArrival - Is this an arriving, not departing, connection? Store connection data only if true.
ex - Exception to print after the delay; may be null
c - Connection being disconnected; may not be null, and unless isArrival, c.getData() may not be null.
Throws:
java.lang.IllegalArgumentException - if c or c.getData is null
See Also:
D.ebugIsEnabled()
Method Detail

run

public void run()
Debug-print connection's arrival or departure, and remove from pending list.

Specified by:
run in interface java.lang.Runnable
Specified by:
run in class java.util.TimerTask