/// <summary> /// Add a new device/thread to communicate with an HikVision camera. /// </summary> /// <param name="plugin">The HikVisionAlarm plugin for HomeSeer.</param> /// <param name="refId">The device reference identifier for HomeSeer.</param> /// <param name="ipAddressStr">The IP address string for the camera.</param> /// <param name="username">The username to use for the camera.</param> /// <param name="password">The password to use for the camera.</param> public static void AddDevice(HSPI plugin, int refId, string ipAddressStr, string username, string password) { HikAlarmThread hikAlarmThread = new HikAlarmThread(); hikAlarmThread.Start(plugin, refId, ipAddressStr, username, password); hikAlarmThreads.Add(hikAlarmThread); }
/// <summary> /// Asynchronous callback for when the camera makes a connection or times out. /// </summary> /// <param name="ar">Access to the thread.</param> private static void ConnectCallback(IAsyncResult ar) { HikAlarmThread thread = (HikAlarmThread)ar.AsyncState; try { // Finish the connection thread.sock.EndConnect(ar); thread.cameraState = CameraStateEnum.Send; } catch (Exception) { // connection failed thread.LogMessage("Connection failed, retry"); thread.cameraState = CameraStateEnum.Wait; } }