From 004ba834a98eb69b095277b7b60fa0d8459f82a0 Mon Sep 17 00:00:00 2001 From: fyf Date: Fri, 13 May 2022 17:39:31 +0800 Subject: [PATCH] uiuiuuiu --- DataVAPI/UpAndDown/ProcessServer.cs | 35 ++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/DataVAPI/UpAndDown/ProcessServer.cs b/DataVAPI/UpAndDown/ProcessServer.cs index d24f65f..82559a2 100644 --- a/DataVAPI/UpAndDown/ProcessServer.cs +++ b/DataVAPI/UpAndDown/ProcessServer.cs @@ -60,7 +60,6 @@ namespace DataVAPI.UpAndDown //MQTT 数据接收处理 ConsoleHelper.WriteInfoLine("尝试连接阿里云."); if (IOTDevServer.GetInstance().CreateLinks(DataBus.ProductKey, DataBus.DeviceName, DataBus.DeviceSecret)) - //if (IOTDevServer.GetInstance().CreateLinks("grgpECHSL7q", "Transit", "562dcc779b918a54c2d6589ec30ee230")) { ConsoleHelper.WriteSuccessLine($"阿里云【Transit】连接成功"); } @@ -91,6 +90,40 @@ namespace DataVAPI.UpAndDown /// private void QueueTask() { + Executer.GetInstance().Start(new Action(() => + { + while (true) + { + try + { + if (!IOTDevServer.GetInstance().GetIsConnected()) + { + + if (IOTDevServer.GetInstance().CreateLinks(DataBus.ProductKey, DataBus.DeviceName, DataBus.DeviceSecret)) + { + ConsoleHelper.WriteSuccessLine($"阿里云【Transit】连接成功"); + //订阅上下线 + Subscribe(IOTDevServer.HeartbeatSubTopic); + + //订阅主播消息 + Subscribe(IOTDevServer.BroadcastTopic); + } + else + { + ConsoleHelper.WriteSuccessLine($"阿里云【Transit】连接失败"); + } + Thread.Sleep(10000); + } + + } + catch (Exception ex) + { + ConsoleHelper.WriteErrorLine(ex.Message); + } + } + + }), "阿里云重新连接"); + Executer.GetInstance().Start(new Action(() => { while (true)