| | |
| | | //最后再断开mqtt连接 |
| | | for (int i = 0; i < list.Count; i++) |
| | | { |
| | | list[i].DisConnect("1"); |
| | | list[i].DisConnectLocalMqttClient("1"); |
| | | } |
| | | list.Clear(); |
| | | oldHomeID = Shared.Common.Config.Instance.HomeId; |
| | |
| | | else
|
| | | {
|
| | | ZbGateway.IsRemote = true;
|
| | | for (int i = 0; i < ZbGateway.GateWayList.Count; i++) |
| | | {
|
| | | ZbGateway.GateWayList[i].DisConnectLocalMqttClient("1"); |
| | | }
|
| | | }
|
| | | |
| | | searchCount--; |
| | |
| | | var gateWay = ZbGateway.GateWayList.Find(obj => obj.getGatewayBaseInfo != null && obj.getGatewayBaseInfo.gwID == zbGateWay.getGatewayBaseInfo.gwID); |
| | | if (gateWay == null) |
| | | {
|
| | | await zbGateWay.StartLocalMqtt(ipAddress); |
| | | ZbGateway.GateWayList.Add(zbGateWay); |
| | | await zbGateWay.StartLocalMqtt(ipAddress); |
| | | NewGateWayAction?.Invoke(zbGateWay); |
| | | } |
| | | else |
| | |
| | | gateWay.GatewayOnlineFlage = true; |
| | | if (gateWay.getGatewayBaseInfo.IpAddress != ipAddress) |
| | | { |
| | | gateWay.DisConnect("2"); |
| | | await gateWay.DisConnectLocalMqttClient("2"); |
| | | ZbGateway.GateWayList.Remove(gateWay); |
| | | gateWay = zbGateWay;
|
| | | await zbGateWay.StartLocalMqtt(ipAddress); |
| | | ZbGateway.GateWayList.Add(gateWay); |
| | | await zbGateWay.StartLocalMqtt(ipAddress); |
| | | } |
| | | else |
| | | { |
| | |
| | | try |
| | | { |
| | | //定时检测远程连接情况 |
| | | await ZbGateway.StartCloudMqtt(); |
| | | await ZbGateway.StartRemoteMqtt(); |
| | | if (!ZbGateway.IsRemote) |
| | | { |
| | | System.Threading.Thread.Sleep(500); |