code: private Future<?> startHeartbeat(final WebSocket websocket, final int heartbeatInterval) {
          // first heartbeat should assume last heartbeat was answered properly
          heartbeatAckReceived.set(true);
          return api.getThreadPool().getScheduler().scheduleWithFixedDelay(() -> {
              try {
                  if (heartbeatAckReceived.getAndSet(false)) {
                      sendHeartbeat(websocket);
                      logger.debug("Sent heartbeat (interval: {})", heartbeatInterval);
                  } else {
                      websocket.sendClose(WebSocketCloseReason.HEARTBEAT_NOT_PROPERLY_ANSWERED.getNumericCloseCode(),
                                          WebSocketCloseReason.HEARTBEAT_NOT_PROPERLY_ANSWERED.getCloseReason());
                  }
              } catch (Throwable t) {
                  logger.error("Failed to send heartbeat or close web socket!", t);
              }
          }, 0, heartbeatInterval, TimeUnit.MILLISECONDS);
      }
docs: Starts the heartbeat.
  
  @param websocket The websocket the heartbeat should be sent to.
  @param heartbeatInterval The heartbeat interval.
  @return The timer used for the heartbeat.