| | |
| | | }
|
| | |
|
| | | /// <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>>();
|
| | |
| | | /// <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(() =>
|
| | |
| | | {
|
| | | if (HdlGatewayLogic.Current.IsGatewayExist(gatewayId) == false)
|
| | | {
|
| | | //不是自己绑定的网关,则不处理
|
| | | //不是自己绑定的网关,则不处理,但是下面这个东西有点特殊
|
| | | if (gatewayId == this.GatewayReceiveId)
|
| | | {
|
| | | this.GatewayReceiveEvent?.Invoke(topic, msgData);
|
| | | }
|
| | | return;
|
| | | }
|
| | | //设备属性上报
|
| | |
| | | else if (topic == gatewayId + "/Scene/Exec_Respon")
|
| | | {
|
| | | this.SceneExecPush(null);
|
| | | }
|
| | | //网关接收事件
|
| | | else if (gatewayId == this.GatewayReceiveId)
|
| | | {
|
| | | this.GatewayReceiveEvent?.Invoke(topic, msgData);
|
| | | }
|
| | | }
|
| | | catch (Exception ex)
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /// <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 ■ 移除设备监听_______________________
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 移除网关接收事件(只能存在一个事件)
|
| | | /// </summary>
|
| | | public void RemoveGatewayReceiveEvent()
|
| | | {
|
| | | this.GatewayReceiveEvent = null;
|
| | | this.GatewayReceiveId = null;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 一般方法___________________________
|