Class HeartBeatSender

java.lang.Object
java.util.TimerTask
it.polimi.ingsw.Network.HeartBeatSender
All Implemented Interfaces:
Runnable

public class HeartBeatSender extends TimerTask
an auto sender of HeartBeatMessage at regular intervals
  • Field Details

  • Constructor Details

    • HeartBeatSender

      public HeartBeatSender(SocketWrapper sw)
      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 each HeartBeatMessage sent
    • run

      public void run()
      sends a HeartBeatMessage over the wrapper. In case of errors during the sending of a message, closes the wrapper and cancels the repeating task from the timer.
      Specified by:
      run in interface Runnable
      Specified by:
      run in class TimerTask