package com.njcn.gather.detection.util.socket.communication.handler;

import com.njcn.gather.detection.util.socket.communication.model.ConnectionContext;

/**
 * Heartbeat protocol strategy for generic client connections.
 * The transport layer only knows when to send and detect heartbeat frames;
 * the concrete heartbeat payload is provided by the business side.
 *
 * @author hongawen
 * @date 2026/04/07
 */
public interface HeartbeatMessageStrategy {

    /**
     * Build the outbound heartbeat packet. Return {@code null} or blank to
     * disable heartbeat sending for the current connection.
     */
    String buildHeartbeatMessage(ConnectionContext context);

    /**
     * Check whether the inbound message is a heartbeat response frame.
     */
    boolean isHeartbeatResponse(ConnectionContext context, String message);
}
