| | |
| | | public List<CommonDevice> DeviceList = new List<CommonDevice>(); |
| | | |
| | | /// <summary> |
| | | /// 所有网关中的设备列表 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public List<CommonDevice> AllGatewayDeviceList = new List<CommonDevice>(); |
| | | |
| | | /// <summary> |
| | | /// 网关中场景列表 |
| | | /// 一个场景中包含所有信息,包括场景设备信息 |
| | | /// </summary> |
| | |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public List<Scene.GetSceneDeviceListInfo> SceneDeviceList = new List<Scene.GetSceneDeviceListInfo>(); |
| | | |
| | | /// <summary> |
| | | /// 网关中hdl私有按键绑定列表 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public List<HDLbutton> HdlButtonList = new List<HDLbutton>(); |
| | | |
| | | //网关中新的设备列表 |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public List<CommonDevice> ListNewDeviceInfoData = new List<CommonDevice>(); |
| | | |
| | | /// <summary> |
| | | /// 私有按键信息列表 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public System.Collections.Generic.Dictionary<string, HDLbutton> hdlButtonInfoList = new Dictionary<string, HDLbutton>(); |
| | | |
| | | /// <summary> |
| | | /// 传感器信息列表 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public System.Collections.Generic.Dictionary<string, Scene.TaskListInfo> sceneTaskInfoList = new Dictionary<string, Scene.TaskListInfo>(); |
| | | |
| | | #region action variable |
| | | /// <summary> |
| | |
| | | {
|
| | | if (localMqttClient.Options == null)
|
| | | {
|
| | | var options = new MQTTnet.Client.Options.MqttClientOptionsBuilder().WithClientId(currentGuid.ToString())
|
| | | .WithTcpServer(brokerName, 1883)
|
| | | .WithKeepAlivePeriod(TimeSpan.FromSeconds(20))
|
| | | .WithCleanSession()
|
| | | //.WithCommunicationTimeout(TimeSpan.FromSeconds(10))
|
| | | .WithCredentials("", "")
|
| | | .Build();
|
| | | await localMqttClient.ConnectAsync(options, CancellationToken.None);
|
| | | var options = new MQTTnet.Client.Options.MqttClientOptionsBuilder()//MQTT连接参数填充
|
| | | .WithClientId(currentGuid.ToString())//客户端ID
|
| | | .WithTcpServer(brokerName, 1883)//TCP服务端 1883 ,即MQTT服务端
|
| | | .WithCredentials("", "")//"", "")//凭证 帐号 密码
|
| | | .WithCommunicationTimeout(new TimeSpan(0, 0, 60)) //重连超时时间,默认5s
|
| | | .WithKeepAlivePeriod(new TimeSpan(0, 0, 15)) //保持连接时间,默认5s,心跳包
|
| | | .Build();//
|
| | | await localMqttClient.ConnectAsync(options);
|
| | | }
|
| | | else
|
| | | {
|
| | |
| | | if (RemoteMqttClient.ApplicationMessageReceivedHandler == null) |
| | | { |
| | | RemoteMqttClient.UseApplicationMessageReceivedHandler((e) => |
| | | { |
| | | if (!RemoteMqttClient.IsConnected || !IsRemote) |
| | | { |
| | | if (e.ApplicationMessage.Topic != "/ZigbeeGateWayToClient/" + Config.Instance.ConnEmqClientId + "/Push/NotifySqueeze")
|
| | | {
|
| | | return;
|
| | | } |
| | | }
|
| | | //如果当前使用的是内网模式
|
| | | if (IsRemote == false)
|
| | | {
|
| | | //这里是特殊的主题
|
| | | if (e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.ConnEmqClientId + "/Push/NotifySqueeze"//踢人下线
|
| | | || e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.Guid + "/Push/Deleted"//分享删除
|
| | | || e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.Guid + "/Push/DeletedShareData"//分享删除
|
| | | || e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.Guid + "/Push/Update"//成员权限变更
|
| | | || e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.Home.Id + "_" + Config.Instance.Guid + "/PrimaryUserDelYou")//子账号被删除
|
| | | {
|
| | | if (e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.ConnEmqClientId + "/Push/NotifySqueeze"//踢人下线
|
| | | || e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.Guid + "/Push/Deleted"//分享删除
|
| | | || e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.Guid + "/Push/DeletedShareData")
|
| | | {
|
| | | mqttRemoteClient_MqttMsgPublishReceived(e);
|
| | | }
|
| | | mqttRemoteClient_MqttMsgPublishReceived(e);
|
| | | return;
|
| | | }
|
| | | if (!RemoteMqttClient.IsConnected || !IsRemote)
|
| | | {
|
| | | return;
|
| | | } |
| | | mqttRemoteClient_MqttMsgPublishReceived(e); |
| | |
| | | await RemoteMqttClient.SubscribeAsync("/ZigbeeGateWayToClient/" + myGuid + "/Push/Deleted");
|
| | | //订阅一个分享数据已经变更的主题
|
| | | await RemoteMqttClient.SubscribeAsync("/ZigbeeGateWayToClient/" + myGuid + "/Push/DeletedShareData");
|
| | | //订阅一个子账号被删除的主题
|
| | | await RemoteMqttClient.SubscribeAsync("/ZigbeeGateWayToClient/" + Config.Instance.Home.Id + "_" + myGuid + "/PrimaryUserDelYou");
|
| | | //订阅一个成员权限已经变更的主题
|
| | | await RemoteMqttClient.SubscribeAsync("/ZigbeeGateWayToClient/" + myGuid + "/Push/Update");
|
| | | }
|
| | | //订阅一个挤下线的主题
|
| | | await RemoteMqttClient.SubscribeAsync("/ZigbeeGateWayToClient/" + Config.Instance.ConnEmqClientId + "/Push/NotifySqueeze");
|