提交 | 用户 | 时间
|
149dd0
|
1 |
package com.iailab.netsdk.demo.module; |
H |
2 |
|
|
3 |
import com.iailab.netsdk.lib.ToolKits; |
|
4 |
import com.iailab.netsdk.lib.NetSDKLib.fMessCallBack; |
|
5 |
|
|
6 |
/** |
|
7 |
* \if ENGLISH_LANG |
|
8 |
* alarm listen interface |
|
9 |
* contains: start and stop alarm listen |
|
10 |
* \else |
|
11 |
* 报警接口实现 |
|
12 |
* 包含 :向设备订阅报警和停止订阅报警 |
|
13 |
* \endif |
|
14 |
*/ |
|
15 |
public class AlarmListenModule { |
|
16 |
|
|
17 |
private static boolean bListening = false; |
|
18 |
|
|
19 |
|
|
20 |
/** |
|
21 |
* \if ENGLISH_LANG |
|
22 |
* start alarm listen |
|
23 |
* \else |
|
24 |
* 向设备订阅报警 |
|
25 |
* \endif |
|
26 |
*/ |
|
27 |
public static boolean startListen(fMessCallBack cbMessage) { |
|
28 |
|
|
29 |
if (bListening) { |
|
30 |
// System.out.println("Had Subscribe Alarm."); |
|
31 |
return true; |
|
32 |
} |
|
33 |
|
|
34 |
LoginModule.netsdk.CLIENT_SetDVRMessCallBack(cbMessage, null); // set alarm listen callback |
|
35 |
|
|
36 |
if (!LoginModule.netsdk.CLIENT_StartListenEx(LoginModule.m_hLoginHandle)) { |
|
37 |
System.err.printf("CLIENT_StartListenEx Failed!" + ToolKits.getErrorCodePrint()); |
|
38 |
return false; |
|
39 |
} else { |
|
40 |
System.out.println("CLIENT_StartListenEx success."); |
|
41 |
} |
|
42 |
|
|
43 |
bListening = true; |
|
44 |
return true; |
|
45 |
} |
|
46 |
|
|
47 |
/** |
|
48 |
* \if ENGLISH_LANG |
|
49 |
* stop alarm listen |
|
50 |
* \else |
|
51 |
* 停止订阅报警 |
|
52 |
* \endif |
|
53 |
*/ |
|
54 |
public static boolean stopListen() { |
|
55 |
|
|
56 |
if (!bListening) { |
|
57 |
return true; |
|
58 |
} |
|
59 |
|
|
60 |
if (!LoginModule.netsdk.CLIENT_StopListen(LoginModule.m_hLoginHandle)) { |
|
61 |
System.err.printf("CLIENT_StopListen Failed!" + ToolKits.getErrorCodePrint()); |
|
62 |
return false; |
|
63 |
} else { |
|
64 |
System.out.println("CLIENT_StopListen success."); |
|
65 |
} |
|
66 |
|
|
67 |
bListening = false; |
|
68 |
return true; |
|
69 |
} |
|
70 |
|
|
71 |
} |
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|