Class HeartbeatClient

java.lang.Object
java.util.TimerTask
it.polimi.ingsw.client.HeartbeatClient
All Implemented Interfaces:
java.lang.Runnable

public class HeartbeatClient
extends java.util.TimerTask
implements java.lang.Runnable
Allows the client to send a ping message to the server, to let him know that the client is still alive. The Ping message is sent at fixed rate.
  • Constructor Summary

    Constructors 
    Constructor Description
    HeartbeatClient​(NetworkHandler clientNetworkHandler)  
  • Method Summary

    Modifier and Type Method Description
    void run()
    Until the connection is alive, sends the ping message to the server at fixed rate.
    void sendPing()
    Sends to the server teh ping message.

    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
  • Constructor Details

  • Method Details

    • run

      public void run()
      Until the connection is alive, sends the ping message to the server at fixed rate. Otherwise stops when connection is shut down.
      Specified by:
      run in interface java.lang.Runnable
      Specified by:
      run in class java.util.TimerTask
    • sendPing

      public void sendPing()
      Sends to the server teh ping message.