wxr
2024-10-12 50ad482974a7e838d11360a84e9e8ff3f7974ab2
HDL_ON/Common/HDLCommon.cs
@@ -247,6 +247,10 @@
        {
            try
            {
                if (OnAppConfig.Instance.LastLoginUserId == "")
                {
                    return;
                }
                //MainPage.Log($"接收到推送,,,,.{Newtonsoft.Json.JsonConvert.SerializeObject(jpushMessageInfo).ToString()}");
                //Extras为空不处理
                if (string.IsNullOrEmpty(jpushMessageInfo.Extras)) return;
@@ -353,37 +357,47 @@
                                    }
                                }
                            }
                            catch (Exception ex) {
                            catch (Exception ex)
                            {
                                MainPage.Log("Error", $"自研可视对讲通知异常:{ex.StackTrace}");
                            }
#if __ANDROID__
                            Com.Hdl.Hdllinphonesdk.HDLLinphoneKit.Instance.MissedCallsTime = 30;
                            Com.Hdl.Hdllinphonesdk.HDLLinphoneKit.Instance.SetMediaPlayerLooping(true);
                            Com.Hdl.Hdllinphonesdk.HDLLinphoneKit.Instance.PlayRingtone();
                            new Thread(() =>
                            try
                            {
                                try
                                //安卓如果设置了静音,不能响铃
                                if (Com.Hdl.Hdllinphonesdk.HDLLinphoneKit.Instance.AudioManager.RingerMode.ToString().ToLower() == "normal")
                                {
                                    DateTime dateTime = DateTime.Now;
                                    while (true)
                                    Com.Hdl.Hdllinphonesdk.HDLLinphoneKit.Instance.MissedCallsTime = 30;
                                    Com.Hdl.Hdllinphonesdk.HDLLinphoneKit.Instance.SetMediaPlayerLooping(true);
                                    Com.Hdl.Hdllinphonesdk.HDLLinphoneKit.Instance.PlayRingtone();
                                    new Thread(() =>
                                    {
                                        Thread.Sleep(1000);
                                        if (!Com.Hdl.Hdllinphonesdk.HDLLinphoneKit.Instance.MediaPlayerPlayingStatus || dateTime.AddSeconds(Com.Hdl.Hdllinphonesdk.HDLLinphoneKit.Instance.MissedCallsTime) <= DateTime.Now)
                                        try
                                        {
                                            break;
                                            DateTime dateTime = DateTime.Now;
                                            while (true)
                                            {
                                                Thread.Sleep(1000);
                                                if (!Com.Hdl.Hdllinphonesdk.HDLLinphoneKit.Instance.MediaPlayerPlayingStatus || dateTime.AddSeconds(Com.Hdl.Hdllinphonesdk.HDLLinphoneKit.Instance.MissedCallsTime) <= DateTime.Now)
                                                {
                                                    break;
                                                }
                                            }
                                            Com.Hdl.Hdllinphonesdk.HDLLinphoneKit.Instance.SetMediaPlayerLooping(false);
                                        }
                                    }
                                    Com.Hdl.Hdllinphonesdk.HDLLinphoneKit.Instance.SetMediaPlayerLooping(false);
                                        catch (Exception ex)
                                        {
                                            MainPage.Log("error", "自研可视对讲铃声播放异常:" + ex.Message);
                                        }
                                    })
                                    { IsBackground = true }.Start();
                                }
                                catch (Exception ex)
                                {
                                    MainPage.Log("error", "自研可视对讲铃声播放异常:" + ex.Message);
                                }
                            })
                            { IsBackground = true }.Start();
                            #elif __IOS__
                            }catch(Exception ex)
                            {
                                MainPage.Log("Error", $"安卓可视对讲响铃异常:{ex.StackTrace}");
                            }
#elif __IOS__
                            SoundPlayer.Ins.PlaySound();
                            new Thread(() => {
                                int count = 0;
@@ -417,7 +431,7 @@
                                }
                            })
                            { IsBackground = true }.Start();
                            #endif
#endif
                            MainPage.Log("接收到推送:HDL Linphone 狄耐克");
                            eSVideoInfo.HomeId = jpushMessageInfo.HomeId;
@@ -459,11 +473,46 @@
                    }
                    else if (jpushMessageInfo.messageType == (PushMessageType.DOOR_BELL.ToString()))
                    {
                        try
                        {
                            var json = Newtonsoft.Json.Linq.JObject.Parse(jpushMessageInfo.expantContent);
                            string interphoneTypeEnum = json["interphoneTypeEnum"].ToString();
                            if (string.IsNullOrEmpty(interphoneTypeEnum)) return;
                            ESVideoInfo eSVideoInfo = new ESVideoInfo();
                            if (interphoneTypeEnum == InterphoneType.EZVIZ.ToString())
                            {
                                eSVideoInfo.Lc_AccessToken = json["subToken"].ToString();//"子账号token
                                eSVideoInfo.DeviceSerial = json["devSerial"].ToString();//设备序列号
                                eSVideoInfo.Lc_DeviceId = json["deviceId"].ToString();
                                eSVideoInfo.spk = json["spk"].ToString();
                                if (eSVideoInfo.spk == SPK.Peephole)
                                {
                                    eSVideoInfo.HomeId = jpushMessageInfo.HomeId;
                                    if (json.ContainsKey("msgId") && !string.IsNullOrEmpty(json["msgId"].ToString()))
                                    {
                                        eSVideoInfo.msgId = json["msgId"].ToString();
                                    }
                                    if (json.ContainsKey("currentTime") && !string.IsNullOrEmpty(json["currentTime"].ToString()))
                                    {
                                        eSVideoInfo.currentTime = json["currentTime"].ToString();
                                    }
                                    if (eSVideoInfo != null)
                                    {
                                        //打开呼叫页面
                                        ESOnVideo.Current.ShowESvideoVideoIntercom(eSVideoInfo, interphoneTypeEnum);
                                        return;
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            MainPage.Log("Error", $"结束门铃推送数据异常:{ex.Message}");
                        }
                        //萤石门锁推送
                        HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock.CommonMethod.Current.DoorLockPush(jpushMessageInfo);
                    }
                }
            }
            catch (Exception EX)
@@ -530,7 +579,7 @@
                Logout();
            }catch (Exception ex)
            {
                MainPage.Log($"挤下线异常:{ex.Message}");
                MainPage.Log("Error",$"挤下线异常:{ex.Message}");
            }
        }