mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-16 17:23:04 +08:00
Fix build errors.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -14,7 +14,7 @@ using MQTTnet.Protocol;
|
||||
|
||||
namespace MQTTnet.Server
|
||||
{
|
||||
public sealed class MqttClient : IDisposable
|
||||
public sealed class MqttClient
|
||||
{
|
||||
readonly Dictionary<ushort, string> _topicAlias = new Dictionary<ushort, string>();
|
||||
readonly MqttPacketDispatcher _packetDispatcher = new MqttPacketDispatcher();
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace MQTTnet.Server
|
||||
_clients.Remove(client.Id);
|
||||
}
|
||||
|
||||
if ((!_options.EnablePersistentSessions) || (!clientConnection.Session.IsPersistent))
|
||||
if ((!_options.EnablePersistentSessions) || !client.Session.IsPersistent)
|
||||
{
|
||||
await DeleteSessionAsync(client.Id).ConfigureAwait(false);
|
||||
}
|
||||
@@ -423,13 +423,13 @@ namespace MQTTnet.Server
|
||||
MqttConnectPacket connectPacket,
|
||||
MqttConnAckPacket connAckPacket,
|
||||
IMqttChannelAdapter channelAdapter,
|
||||
MqttConnectionValidatorContext context)
|
||||
ValidatingConnectionEventArgs validatingConnectionEventArgs)
|
||||
{
|
||||
MqttClient connection;
|
||||
|
||||
bool sessionShouldPersist;
|
||||
|
||||
if (context.ProtocolVersion == MqttProtocolVersion.V500)
|
||||
if (validatingConnectionEventArgs.ProtocolVersion == MqttProtocolVersion.V500)
|
||||
{
|
||||
// MQTT 5.0 section 3.1.2.11.2
|
||||
// The Client and Server MUST store the Session State after the Network Connection is closed if the Session Expiry Interval is greater than 0 [MQTT-3.1.2-23].
|
||||
@@ -439,7 +439,7 @@ namespace MQTTnet.Server
|
||||
// in each time it connects.
|
||||
|
||||
// Persist if SessionExpiryInterval != 0, but may start with a clean session
|
||||
sessionShouldPersist = context.SessionExpiryInterval != 0;
|
||||
sessionShouldPersist = validatingConnectionEventArgs.SessionExpiryInterval != 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -459,14 +459,14 @@ namespace MQTTnet.Server
|
||||
{
|
||||
if (!_sessions.TryGetValue(connectPacket.ClientId, out session))
|
||||
{
|
||||
session = CreateSession(connectPacket.ClientId, sessionItems, context.SessionItems, sessionShouldPersist);
|
||||
session = CreateSession(connectPacket.ClientId, validatingConnectionEventArgs.SessionItems, sessionShouldPersist);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (connectPacket.CleanSession)
|
||||
{
|
||||
_logger.Verbose("Deleting existing session of client '{0}'.", connectPacket.ClientId);
|
||||
session = CreateSession(connectPacket.ClientId, context.SessionItems, sessionShouldPersist);
|
||||
session = CreateSession(connectPacket.ClientId, validatingConnectionEventArgs.SessionItems, sessionShouldPersist);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -573,12 +573,13 @@ namespace MQTTnet.Server
|
||||
_rootLogger);
|
||||
}
|
||||
|
||||
MqttClientSession CreateSession(string clientId, IDictionary<object, object> sessionItems, bool isPersistent)
|
||||
MqttSession CreateSession(string clientId, IDictionary<object, object> sessionItems, bool isPersistent)
|
||||
{
|
||||
_logger.Verbose("Created a new session for client '{0}'.", clientId);
|
||||
|
||||
return new MqttSession(
|
||||
clientId,
|
||||
isPersistent,
|
||||
sessionItems,
|
||||
_options,
|
||||
_eventContainer,
|
||||
@@ -590,11 +591,6 @@ namespace MQTTnet.Server
|
||||
{
|
||||
_createConnectionSyncRoot?.Dispose();
|
||||
|
||||
foreach (var clientConnection in _clients.Values)
|
||||
{
|
||||
clientConnection.Dispose();
|
||||
}
|
||||
|
||||
foreach (var session in _sessions.Values)
|
||||
{
|
||||
session.Dispose();
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace MQTTnet.Tests.Server
|
||||
|
||||
var session = new MqttSession(
|
||||
"",
|
||||
false,
|
||||
new ConcurrentDictionary<object, object>(),
|
||||
options,
|
||||
eventContainer,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
@@ -45,7 +45,7 @@ namespace MQTTnet.Tests.Server
|
||||
{
|
||||
e.ApplicationMessage.Payload =
|
||||
Encoding.UTF8.GetBytes(
|
||||
e.SessionItems["default_payload"] as string ?? String.Empty);
|
||||
e.SessionItems["default_payload"] as string ?? string.Empty);
|
||||
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
@@ -192,7 +192,7 @@ namespace MQTTnet.Tests.Server
|
||||
{
|
||||
c.AutoAcknowledge = false;
|
||||
++count;
|
||||
Console.WriteLine("process");
|
||||
System.Console.WriteLine("process");
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user