wxr
2024-09-02 02ef7fd8315dfa7a5d8d3ddc0d04a3d4625dc0b5
HDL_ON/Common/HDLCommon.cs
@@ -7,6 +7,10 @@
using HDL_ON.Entity;
using System.Threading;
using HDL_ON.DriverLayer;
#if __IOS__
using Other;
using Shared.IOS.HDLLinphoneSDK;
#endif
namespace HDL_ON
{
    /// <summary>
@@ -305,35 +309,14 @@
                        ESOnVideo.Current.ShowESvideoVideoIntercom(eSVideoInfo, InterphoneType.FLVI.ToString());
                    }
                    else if (jpushMessageInfo.messageType == (PushMessageType.HDL_INTERPHONE.ToString()))
                    else if (jpushMessageInfo.messageType == PushMessageType.HDL_INTERPHONE.ToString())
                    {
                        if (string.IsNullOrEmpty(jpushMessageInfo.expantContent)) return;
                        //字段兼容问题,只能直接取值了
                        var json = Newtonsoft.Json.Linq.JObject.Parse(jpushMessageInfo.expantContent);
                        try
                        {
                            //var pushHomeId = json["homeId"];
                            //if (pushHomeId == null || string.IsNullOrEmpty(pushHomeId.ToString())){
                            //    Console.WriteLine("homeId is null");
                            //    return;
                            //}
                            var pushTime = json["pushTime"];
                            if(pushTime == null)
                            {
                                return;
                            }
                            if (!string.IsNullOrEmpty(pushTime.ToString()))
                            {
                                var pushDateTime = Utlis.UnixToDateTimeMS(Convert.ToInt64(pushTime));
                                if (pushDateTime.AddSeconds(30) < DateTime.Now)
                                {
                                    return;
                                }
                            }
                        }
                        catch { }
                        //1.视对讲厂家类型
                        string interphoneTypeEnum = json["interphoneTypeEnum"].ToString();
@@ -372,6 +355,89 @@
                        }
                        else if (interphoneTypeEnum == InterphoneType.HDL.ToString())
                        {
                            try
                            {
                                var pushTime = json["pushTime"];
                                if (pushTime == null)
                                {
                                    return;
                                }
                                if (!string.IsNullOrEmpty(pushTime.ToString()))
                                {
                                    var pushDateTime = Utlis.UnixToDateTimeMS(Convert.ToInt64(pushTime));
                                    if (pushDateTime.AddSeconds(30) < DateTime.Now)
                                    {
                                        return;
                                    }
                                }
                            }
                            catch { }
#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
                                {
                                    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);
                                }
                                catch (Exception ex)
                                {
                                    MainPage.Log("error", "自研可视对讲铃声播放异常:" + ex.Message);
                                }
                            })
                            { IsBackground = true }.Start();
#elif __IOS__
                            SoundPlayer.Ins.PlaySound();
                            new Thread(() => {
                                int count = 0;
                                while (true)
                                {
                                    if (SoundPlayer.Ins.player == null)
                                    {
                                        break;
                                    }
                                    if (!SoundPlayer.Ins.player.Playing)
                                    {
                                        break;
                                    }
                                    System.Threading.Thread.Sleep(1000);
                                    count++;
                                    MainPage.Log("linphone 呼叫计时:" + count);
                                    if (count > 29)
                                    {
                                        SoundPlayer.Ins.StopSound();
                                        Application.RunOnMainThread(() => {
                                            try
                                            {
                                                HDLLinPhoneSDK.Instance().HideIntercomeVC();
                                            }catch(Exception ex)
                                            {
                                                MainPage.Log("error", "ios linphone 呼叫超时关闭界面异常:" + ex.Message);
                                            }
                                        });
                                        break;
                                    }
                                }
                            })
                            { IsBackground = true }.Start();
#endif
                            //HDL Linphone 狄耐克
                            eSVideoInfo.HomeId = jpushMessageInfo.HomeId;
                            eSVideoInfo.callId = json["callId"].ToString();
@@ -379,6 +445,7 @@
                            eSVideoInfo.DeviceName = json["deviceName"].ToString();
                            eSVideoInfo.deviceSipAccount = json["deviceSipAccount"].ToString();
                            eSVideoInfo.spk = json["spk"].ToString();
                            //ShowAlert("狄耐克门口机呼叫");
                            //打开呼叫页面
@@ -473,6 +540,7 @@
                case "13580507523":
                case "15626203746":
                case "18316672920":
                    return;
            }
@@ -689,7 +757,7 @@
            if (internetStatus == 0)//没有网络连接 0
            {
                MainPage.InternetStatus = 0;
                DAL.Mqtt.MqttClient.InitState();
                //DAL.Mqtt.MqttClient.DisConnectRemote();//.InitState();
            }
            else if (internetStatus == 1)//3,4G的网络连接 1
            {
@@ -775,7 +843,8 @@
                                        ((BaseActivity)Shared.Application.Activity).SetPermission(result =>
                                        {
                                            //2023年03月29日13:08:35 修改
                                            Com.Videogo.Hdl.HDLEzvizSdk.Instance.Init(Application.Activity.Application, ezChildAccessToken, UserInfo.Current.LoginTokenString, UserInfo.Current.RefreshToken, OnAppConfig.Instance.RequestHttpsHost, "1aa98a90489b4838b966b57018b4b04b", 1, DB_ResidenceData.Instance.CurrentRegion.id);
                                            Com.Videogo.Hdl.HDLEzvizSdk.Instance.Init(Application.Activity.Application, ezChildAccessToken, UserInfo.Current.LoginTokenString, UserInfo.Current.RefreshToken, OnAppConfig.Instance.RequestHttpsHost, "1aa98a90489b4838b966b57018b4b04b", 1, DB_ResidenceData.Instance.CurrentRegion.id,
                                HttpUtil.APP_KEY, HttpUtil.SECRET_KEY);
                                            Com.Videogo.Hdl.HDLEzvizSdk.Instance.JumpToCameraListActivity(Shared.Application.Activity, list);
                                            //if (result)
                                            //{
@@ -805,7 +874,8 @@
                    }
                    else
                    {
                        IMessageCommon.Current.ShowErrorInfoAlter(result.Code);
                        if (result.Code != "-1")
                            IMessageCommon.Current.ShowErrorInfoAlter(result.Code);
                    }
                }
                catch (Exception ex)