package com.iailab.module.data.video.dahua;

import com.alibaba.fastjson.JSON;
import com.iailab.module.data.common.utils.HttpRequest;
import com.iailab.netsdk.lib.NetSDKLib;
import com.sun.jna.Pointer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;


/**
 * 断线回调
 *
 * @author PanZhibao
 * @Description
 * @createTime 2024年03月06日
 */
public class DisConnect implements NetSDKLib.fDisConnect {
    private Logger logger = LoggerFactory.getLogger(getClass());

    private String url = "http://127.0.0.1:8080/iailab/api/dis-connect";

    @Override
    public void invoke(NetSDKLib.LLong m_hLoginHandle, String pchDVRIP, int nDVRPort, Pointer dwUser) {
        logger.info("Device[%s] Port[%d] DisConnect!\n", pchDVRIP, nDVRPort);
        Map<String, String> params = new HashMap<>();
        params.put("pchDVRIP", pchDVRIP);
        params.put("nDVRPort", Integer.valueOf(nDVRPort).toString());
        HttpRequest.doPost(url, JSON.toJSONString(params), "utf-8", "");
    }
}