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