1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.ruoyi.device.hiksdk.sdk;
 
import com.ruoyi.device.camera.domain.ArdCameras;
import com.ruoyi.device.hiksdk.common.GlobalVariable;
import com.sun.jna.Pointer;
import javafx.scene.Camera;
import lombok.extern.slf4j.Slf4j;
 
import static com.ruoyi.device.hiksdk.sdk.HCNetSDK.*;
 
/**
 * @Description: 注册接收异常、重连等消息的窗口句柄或回调函数
 * @ClassName: ExceptionCallBack
 * @Author: 刘苏义
 * @Date: 2023年10月23日15:37:40
 **/
@Slf4j(topic = "hikSdk")
public class ExceptionCallBack implements HCNetSDK.FExceptionCallBack {
    @Override
    public void invoke(int dwType, int lUserID, int lHandle, Pointer pUser) {
        ArdCameras camera = (ArdCameras) GlobalVariable.loginCameraMap.get(lUserID);
        if(camera!=null) {
            String ip = camera.getIp();
            Integer port = camera.getPort();
            switch (dwType) {
                case EXCEPTION_EXCHANGE:
                    log.warn("Device[" + ip + "] Port[" + port + "]用户交互时异常");
                    break;
                case EXCEPTION_PREVIEW:
                    log.warn("Device[" + ip + "] Port[" + port + "]网络预览异常");
                    break;
                case EXCEPTION_RECONNECT:
                    log.warn("Device[" + ip + "] Port[" + port + "]预览时重连");
                    break;
                case RELOGIN_SUCCESS:
                    log.warn("Device[" + ip + "] Port[" + port + "]用户重登陆成功");
                    break;
                case EXCEPTION_RELOGIN:
                    log.warn("Device[" + ip + "] Port[" + port + "]用户重登陆");
                    break;
            }
        }
    }
}