Package it.polimi.ingsw.Network
Class HeartBeatTimeoutTask
java.lang.Object
java.util.TimerTask
it.polimi.ingsw.Network.HeartBeatTimeoutTask
- All Implemented Interfaces:
Runnable
Timeout timer task waiting to close the socket in case it is not cancelled in time.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatePrivate constructor setting up the attributes for the timeout task -
Method Summary
Modifier and TypeMethodDescriptionvoidrun()static TimerstartAndGetTimer(SocketWrapper socketWrapper, long timeoutDuration) Sets up a single, non repeating timer counting down to the timeout.Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
-
Field Details
-
sock
-
-
Constructor Details
-
HeartBeatTimeoutTask
Private constructor setting up the attributes for the timeout task- Parameters:
sock- the socket to close in case of timeout
-
-
Method Details
-
startAndGetTimer
Sets up a single, non repeating timer counting down to the timeout.- Parameters:
socketWrapper- the socket to close if the timer runs outtimeoutDuration- the timeout duration in milliseconds- Returns:
- the timer that is counting down the timeout, calling
Timer.cancel()on it will prevent the timeout task from running, effectively resetting the timeout.
-
run
public void run()
-