Package it.polimi.ingsw.Network
Class HeartBeatSender
java.lang.Object
java.util.TimerTask
it.polimi.ingsw.Network.HeartBeatSender
- All Implemented Interfaces:
Runnable
an auto sender of
HeartBeatMessage at regular intervals-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates the sender but does not activate it -
Method Summary
Modifier and TypeMethodDescriptionvoidrun()sends aHeartBeatMessageover the wrapper.voidstart(long keepAlivePeriod) Activates the sender.Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
-
Field Details
-
sw
-
timer
-
-
Constructor Details
-
HeartBeatSender
Creates the sender but does not activate it- Parameters:
sw- the socket to send heartbeats on
-
-
Method Details
-
start
public void start(long keepAlivePeriod) Activates the sender. The sender will stop running only if externally stopped or if the socketwrapper handling it has issues during delivery of a heartbeat.- Parameters:
keepAlivePeriod- the time, in milliseconds, between eachHeartBeatMessagesent
-
run
public void run()sends aHeartBeatMessageover the wrapper. In case of errors during the sending of a message, closes the wrapper and cancels the repeating task from the timer.
-