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

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

/**
 * Connection lifecycle callback for the retained communication foundation.
 * Business modules can attach optional callbacks here without leaking their
 * own service types into Netty and WebSocket infrastructure.
 *
 * @author hongawen
 * @date 2026/04/07
 */
public interface ConnectionLifecycleHandler {

    ConnectionLifecycleHandler NO_OP = new ConnectionLifecycleHandler() {
    };

    default void onConnected(ConnectionContext context) {
    }

    default void onDisconnected(ConnectionContext context) {
    }

    default void onConnectFailed(ConnectionContext context, Throwable cause) {
    }

    default void onIdleTimeout(ConnectionContext context) {
    }

    default void onMessageHandlingError(ConnectionContext context, String message, Throwable cause) {
    }

    default void onException(ConnectionContext context, Throwable cause) {
    }
}
