|
|
@@ -1,7 +1,10 @@ |
|
|
|
using BPA.KitChen.GroupMeal.Core.Common; |
|
|
|
using BPA.KitChen.GroupMeal.Handlers; |
|
|
|
using BPA.KitChen.GroupMeal.SqlSugar; |
|
|
|
using BPA.MQTTClient; |
|
|
|
using Furion; |
|
|
|
using MQTTnet.Client.Connecting; |
|
|
|
using MQTTnet.Client.Disconnecting; |
|
|
|
using Newtonsoft.Json.Linq; |
|
|
|
using SqlSugar; |
|
|
|
using XExten.Advance.LinqFramework; |
|
|
@@ -10,8 +13,37 @@ var builder = WebApplication.CreateBuilder(args).Inject(); |
|
|
|
|
|
|
|
//JWT¼øȨ |
|
|
|
builder.Services.AddJwt<JwtHandler>(enableGlobalAuthorize: true); |
|
|
|
builder.Services.AddMqttClientHostedService(op => |
|
|
|
{ |
|
|
|
op.Port = int.Parse(App.Configuration["dev1_brokerHostSettings:Port"]); |
|
|
|
op.Server = App.Configuration["dev1_brokerHostSettings:Host"]; |
|
|
|
op.UserName = App.Configuration["MqttClientSettings:UserName"]; |
|
|
|
op.Password = App.Configuration["MqttClientSettings:Password"]; |
|
|
|
op.mqttClientConnectedHandlerDelegate = new MqttClientConnectedHandlerDelegate(async e => |
|
|
|
{ |
|
|
|
Console.WriteLine("MQTTÁ¬½Ó³É¹¦"); |
|
|
|
}); |
|
|
|
op.mqttClientDisconnectedHandlerDelegate = new MqttClientDisconnectedHandlerDelegate(async e => |
|
|
|
{ |
|
|
|
Console.WriteLine("MQTT¶Ï¿ªÁ¬½Ó"); |
|
|
|
await Task.Delay(TimeSpan.FromSeconds(5)); |
|
|
|
try |
|
|
|
{ |
|
|
|
//var options = op.Server.GetService<IMqttClientOptions>(); |
|
|
|
//await op.Server.GetService<IMqttClient>().ConnectAsync(options); |
|
|
|
} |
|
|
|
catch (global::System.Exception) |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
op.MqttApplicationMessageReceivedHandler = new MQTTnet.Client.Receiving.MqttApplicationMessageReceivedHandlerDelegate(async e => |
|
|
|
{ |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
CosConfig.cosInfoOptions = new CosInfoOptions(App.Configuration["cos_config:AppId"], |
|
|
|
App.Configuration["cos_config:Region"], App.Configuration["cos_config:Bucket"], |
|
|
|