浏览代码

防止匿名对象被回收

yingp 6 年之前
父节点
当前提交
9a66c3ed02

+ 0 - 1
applications/device/device-sdk-dahua/src/main/java/com/usoftchina/smartschool/device/dahua/lib/DahuaLibrary.java

@@ -776,7 +776,6 @@ public interface DahuaLibrary extends Library {
                     ", byLeftLogTimes=" + (byLeftLogTimes & 0xff) +
                     ", bReserved=" + new String(bReserved) +
                     ", nLockLeftTime=" + nLockLeftTime +
-                    ", Reserved=" + Arrays.toString(Reserved) +
                     '}';
         }
     }

+ 3 - 1
applications/device/device-sdk-dahua/src/main/java/com/usoftchina/smartschool/device/dahua/service/DahuaDeviceService.java

@@ -28,6 +28,7 @@ public class DahuaDeviceService implements DeviceApi {
      * 多个设备的登录句柄
      */
     private Map<DeviceId, NativeLong> loginHandles;
+    private NET_DEVICEINFO_Ex deviceInfo;
     private final Logger logger = LoggerFactory.getLogger(DahuaDeviceService.class);
     private final DahuaDataAnalyzeService dataAnalyzeService;
 
@@ -59,8 +60,9 @@ public class DahuaDeviceService implements DeviceApi {
      */
     private NativeLong login(String m_strIp, int m_nPort, String m_strUser, String m_strPassword) {
         IntByReference nError = new IntByReference(0);
+        deviceInfo = new NET_DEVICEINFO_Ex();
         NativeLong m_hLoginHandle = sdk.getInstance().CLIENT_LoginEx2(m_strIp, m_nPort, m_strUser, m_strPassword,
-                0, null, new NET_DEVICEINFO_Ex(), nError);
+                EM_LOGIN_SPAC_CAP_TYPE.EM_LOGIN_SPEC_CAP_TCP, null, deviceInfo, nError);
         if (m_hLoginHandle.longValue() == 0) {
             DahuaSdkError error = sdk.getLastError();
             logger.error("Device[{}] Port[{}] Login Failed. Last Error[{}]", m_strIp, m_nPort, error);