package fr.titionfire.ffsaf.net2.packet;

import fr.titionfire.ffsaf.net2.ServerCustom;
import fr.titionfire.ffsaf.net2.data.SimpleCombModel;
import jakarta.enterprise.context.ApplicationScoped;
import org.jboss.logging.Logger;

import java.util.HashMap;

@ApplicationScoped
public class RComb {
    private static final Logger LOGGER = Logger.getLogger(RComb.class);

    final CIA<Long> findByIdOptionalComb = new CIA<>(Long.class, (client_Thread, message) -> {
        try {
            SimpleCombModel combModel = ServerCustom.getInstance().membreService.findByIdOptionalComb(message.data());
            client_Thread.sendRepTo(combModel, message);
        } catch (Throwable e) {
            LOGGER.error(e.getMessage(), e);
            client_Thread.sendErrTo(e.getMessage(), message);
        }
    });

    public static void register(HashMap<String, IAction> iMap) {
        RComb rComb = new RComb();

        iMap.put("findByIdOptionalComb", rComb.findByIdOptionalComb);
    }
}
