From cf872a0b5a4e0364cd3a612033eabcab5a92d4c9 Mon Sep 17 00:00:00 2001 From: MysticBoy Date: Mon, 7 Feb 2022 19:19:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8mqttnet=204.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IoTSharp.Data.MySQL.csproj | 2 +- .../IoTSharp.Data.Oracle.csproj | 2 +- .../IoTSharp.Data.PostgreSQL.csproj | 12 +++++------ .../IoTSharp.Data.SqlServer.csproj | 2 +- .../IoTSharp.Data.Sqlite.csproj | 2 +- IoTSharp.Data/IoTSharp.Data.csproj | 2 +- .../IoTSharp.Sdk.MQTT.csproj | 2 +- IoTSharp/Dtos/DeviceDetailDto.cs | 4 ++-- IoTSharp/Extensions/MqttExtension.cs | 1 + IoTSharp/Handlers/MQTTServerHandler.cs | 4 ++-- IoTSharp/IoTSharp.csproj | 20 +++++++++---------- IoTSharp/Models/Graph/DeviceProp.cs | 3 ++- IoTSharp/Models/Graph/Shape.cs | 4 ++-- 13 files changed, 31 insertions(+), 29 deletions(-) diff --git a/IoTSharp.Data.MySQL/IoTSharp.Data.MySQL.csproj b/IoTSharp.Data.MySQL/IoTSharp.Data.MySQL.csproj index 307c993d..25369d22 100644 --- a/IoTSharp.Data.MySQL/IoTSharp.Data.MySQL.csproj +++ b/IoTSharp.Data.MySQL/IoTSharp.Data.MySQL.csproj @@ -15,7 +15,7 @@ - + diff --git a/IoTSharp.Data.Oracle/IoTSharp.Data.Oracle.csproj b/IoTSharp.Data.Oracle/IoTSharp.Data.Oracle.csproj index 1562e5f6..46f24abd 100644 --- a/IoTSharp.Data.Oracle/IoTSharp.Data.Oracle.csproj +++ b/IoTSharp.Data.Oracle/IoTSharp.Data.Oracle.csproj @@ -8,7 +8,7 @@ - + diff --git a/IoTSharp.Data.PostgreSQL/IoTSharp.Data.PostgreSQL.csproj b/IoTSharp.Data.PostgreSQL/IoTSharp.Data.PostgreSQL.csproj index 22685f94..cac4a1ae 100644 --- a/IoTSharp.Data.PostgreSQL/IoTSharp.Data.PostgreSQL.csproj +++ b/IoTSharp.Data.PostgreSQL/IoTSharp.Data.PostgreSQL.csproj @@ -14,12 +14,12 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - + + + + + + diff --git a/IoTSharp.Data.SqlServer/IoTSharp.Data.SqlServer.csproj b/IoTSharp.Data.SqlServer/IoTSharp.Data.SqlServer.csproj index 7405113e..3383c432 100644 --- a/IoTSharp.Data.SqlServer/IoTSharp.Data.SqlServer.csproj +++ b/IoTSharp.Data.SqlServer/IoTSharp.Data.SqlServer.csproj @@ -8,7 +8,7 @@ - + diff --git a/IoTSharp.Data.Sqlite/IoTSharp.Data.Sqlite.csproj b/IoTSharp.Data.Sqlite/IoTSharp.Data.Sqlite.csproj index e29d7ecd..e8a746b2 100644 --- a/IoTSharp.Data.Sqlite/IoTSharp.Data.Sqlite.csproj +++ b/IoTSharp.Data.Sqlite/IoTSharp.Data.Sqlite.csproj @@ -14,7 +14,7 @@ - + diff --git a/IoTSharp.Data/IoTSharp.Data.csproj b/IoTSharp.Data/IoTSharp.Data.csproj index 22ff5d07..17116512 100644 --- a/IoTSharp.Data/IoTSharp.Data.csproj +++ b/IoTSharp.Data/IoTSharp.Data.csproj @@ -9,7 +9,7 @@ - + diff --git a/IoTSharp.SDKs/IoTSharp.Sdk.MQTT/IoTSharp.Sdk.MQTT.csproj b/IoTSharp.SDKs/IoTSharp.Sdk.MQTT/IoTSharp.Sdk.MQTT.csproj index 9654331a..b1d029b4 100644 --- a/IoTSharp.SDKs/IoTSharp.Sdk.MQTT/IoTSharp.Sdk.MQTT.csproj +++ b/IoTSharp.SDKs/IoTSharp.Sdk.MQTT/IoTSharp.Sdk.MQTT.csproj @@ -15,7 +15,7 @@ - + diff --git a/IoTSharp/Dtos/DeviceDetailDto.cs b/IoTSharp/Dtos/DeviceDetailDto.cs index c39fe787..c300934e 100644 --- a/IoTSharp/Dtos/DeviceDetailDto.cs +++ b/IoTSharp/Dtos/DeviceDetailDto.cs @@ -48,9 +48,9 @@ namespace IoTSharp.Dtos public string IdentityValue { get; set; } public string IdentityId { get; set; } - +#nullable enable public DeviceModel? Model { get; set; } - +#nullable disable } } diff --git a/IoTSharp/Extensions/MqttExtension.cs b/IoTSharp/Extensions/MqttExtension.cs index d20c4fd4..fe6b052c 100644 --- a/IoTSharp/Extensions/MqttExtension.cs +++ b/IoTSharp/Extensions/MqttExtension.cs @@ -46,6 +46,7 @@ namespace IoTSharp { options.WithoutEncryptedEndpoint(); } + options.WithDefaultCommunicationTimeout(TimeSpan.FromSeconds(5)); options.WithPersistentSessions(); options.Build(); }).AddMqttConnectionHandler() diff --git a/IoTSharp/Handlers/MQTTServerHandler.cs b/IoTSharp/Handlers/MQTTServerHandler.cs index 6f162333..8b4b6651 100644 --- a/IoTSharp/Handlers/MQTTServerHandler.cs +++ b/IoTSharp/Handlers/MQTTServerHandler.cs @@ -52,7 +52,7 @@ namespace IoTSharp.Handlers static long clients = 0; internal Task Server_ClientConnectedAsync(ClientConnectedEventArgs e) { - _logger.LogInformation($"Client [{e.ClientId}] connected"); + _logger.LogInformation($"Client [{e.ClientId}] {e.Endpoint} {e.UserName} connected"); clients++; return Task.CompletedTask; } @@ -366,7 +366,7 @@ namespace IoTSharp.Handlers var devtmp = _dbContext.Device.FirstOrDefault(d => d.Id == dev.Id); devtmp.LastActive = DateTime.Now; devtmp.Online = false; - _dbContext.SaveChanges(); + await _dbContext.SaveChangesAsync(); _logger.LogInformation($"Server_ClientDisconnected ClientId:{args.ClientId} DisconnectType:{args.DisconnectType} Device is {devtmp.Name }({devtmp.Id}) "); } } diff --git a/IoTSharp/IoTSharp.csproj b/IoTSharp/IoTSharp.csproj index da3afaf9..7c55544c 100644 --- a/IoTSharp/IoTSharp.csproj +++ b/IoTSharp/IoTSharp.csproj @@ -68,7 +68,7 @@ - + @@ -89,14 +89,14 @@ - - - - - - - - + + + + + + + + @@ -123,7 +123,7 @@ - + diff --git a/IoTSharp/Models/Graph/DeviceProp.cs b/IoTSharp/Models/Graph/DeviceProp.cs index 40eccbf1..0b58e152 100644 --- a/IoTSharp/Models/Graph/DeviceProp.cs +++ b/IoTSharp/Models/Graph/DeviceProp.cs @@ -2,10 +2,11 @@ { public class DeviceProp { - +#nullable enable public Body? body { get; set; } public Position? position { get; set; } public Size? size { get; set; } public Text? text { get; set; } +#nullable disable } } \ No newline at end of file diff --git a/IoTSharp/Models/Graph/Shape.cs b/IoTSharp/Models/Graph/Shape.cs index 94879e05..03276e01 100644 --- a/IoTSharp/Models/Graph/Shape.cs +++ b/IoTSharp/Models/Graph/Shape.cs @@ -8,10 +8,10 @@ public long[] incomes { get; set; } public long[] outgoings { get; set; } - +#nullable enable public DeviceProp? prop { get; set; } - +#nullable disable } } \ No newline at end of file -- GitLab