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
-
Constructor Summary
ConstructorDescriptionCreates the sender but does not activate it -
Method Summary
Modifier and TypeMethodDescriptionvoid
run()
sends aHeartBeatMessage
over the wrapper.void
start
(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 eachHeartBeatMessage
sent
-
run
public void run()sends aHeartBeatMessage
over the wrapper. In case of errors during the sending of a message, closes the wrapper and cancels the repeating task from the timer.
-