黄学彪
2020-11-19 9ef48d7b2da7c408b53f73be0f6eef3cbac1c84a
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayReceiveLogic.cs
@@ -33,6 +33,14 @@
        }
        /// <summary>
        /// 网关接收事件(参数1:主题 参数2:推送消息)
        /// </summary>
        private Action<string, string> GatewayReceiveEvent = null;
        /// <summary>
        /// 接收网关的id
        /// </summary>
        private string GatewayReceiveId = null;
        /// <summary>
        /// 设备推送事件集合
        /// </summary>
        private Dictionary<string, Action<CommonDevice>> dicDeviceEvent = new Dictionary<string, Action<CommonDevice>>();
@@ -54,6 +62,11 @@
        /// <param name="msgData">接收的数据</param>
        public void GatewayOverallMsgReceive(string gatewayId, string topic, string reportTopic, string msgData)
        {
            //如果它在登陆界面,则不做任何处理
            if (Common.Config.Instance.HomeId == string.Empty)
            {
                return;
            }
            if (topic == "AppNoLogin")
            {
                HdlThreadLogic.Current.RunMain(() =>
@@ -141,7 +154,11 @@
            {
                if (HdlGatewayLogic.Current.IsGatewayExist(gatewayId) == false)
                {
                    //不是自己绑定的网关,则不处理
                    //不是自己绑定的网关,则不处理,但是下面这个东西有点特殊
                    if (gatewayId == this.GatewayReceiveId)
                    {
                        this.GatewayReceiveEvent?.Invoke(topic, msgData);
                    }
                    return;
                }
                //设备属性上报
@@ -194,6 +211,11 @@
                else if (topic == gatewayId + "/Scene/Exec_Respon")
                {
                    this.SceneExecPush(null);
                }
                //网关接收事件
                else if (gatewayId == this.GatewayReceiveId)
                {
                    this.GatewayReceiveEvent?.Invoke(topic, msgData);
                }
            }
            catch (Exception ex)
@@ -1115,6 +1137,18 @@
            }
        }
        /// <summary>
        /// 添加网关接收事件(action只能存在一个,与AddAttributeEvent不共存,AddAttributeEvent优先)
        /// </summary>
        /// <param name="i_gatewayId">网关id</param>
        /// <param name="action">只能存在一个action (参数1:主题 参数2:推送消息)</param>
        public void AddGatewayReceiveEvent(string i_gatewayId, Action<string, string> action)
        {
            //添加事件
            this.GatewayReceiveEvent = action;
            this.GatewayReceiveId = i_gatewayId;
        }
        #endregion
        #region ■ 移除设备监听_______________________
@@ -1158,6 +1192,15 @@
            }
        }
        /// <summary>
        /// 移除网关接收事件(只能存在一个事件)
        /// </summary>
        public void RemoveGatewayReceiveEvent()
        {
            this.GatewayReceiveEvent = null;
            this.GatewayReceiveId = null;
        }
        #endregion
        #region ■ 一般方法___________________________