mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-20 19:58:57 +08:00
Fix build errors and several warnings
This commit is contained in:
@@ -32,20 +32,16 @@ namespace MQTTnet.Extensions.TopicTemplate
|
|||||||
{
|
{
|
||||||
throw new ArgumentException("message does not have a response topic");
|
throw new ArgumentException("message does not have a response topic");
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.WithTopic(message.ResponseTopic).WithCorrelationData(message.CorrelationData);
|
return builder.WithTopic(message.ResponseTopic).WithCorrelationData(message.CorrelationData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set the filter topic according to the template, with
|
/// Set the filter topic according to the template, with
|
||||||
/// remaining template parameters substituted by single-level
|
/// remaining template parameters substituted by single-level
|
||||||
/// wildcard.
|
/// wildcard.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param
|
/// <param
|
||||||
/// name="builder">
|
|
||||||
/// a filter builder
|
|
||||||
/// </param>
|
|
||||||
/// <param
|
|
||||||
/// name="topicTemplate">
|
/// name="topicTemplate">
|
||||||
/// a topic template
|
/// a topic template
|
||||||
/// </param>
|
/// </param>
|
||||||
@@ -58,7 +54,7 @@ namespace MQTTnet.Extensions.TopicTemplate
|
|||||||
{
|
{
|
||||||
return new MqttTopicFilterBuilder().WithTopicTemplate(topicTemplate, subscribeTreeRoot);
|
return new MqttTopicFilterBuilder().WithTopicTemplate(topicTemplate, subscribeTreeRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return a message builder to respond to this message. The
|
/// Return a message builder to respond to this message. The
|
||||||
/// message's response topic and correlation data are included
|
/// message's response topic and correlation data are included
|
||||||
@@ -75,7 +71,7 @@ namespace MQTTnet.Extensions.TopicTemplate
|
|||||||
{
|
{
|
||||||
return new MqttApplicationMessageBuilder().AsResponseTo(message);
|
return new MqttApplicationMessageBuilder().AsResponseTo(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return whether the message matches the given topic template.
|
/// Return whether the message matches the given topic template.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -96,7 +92,7 @@ namespace MQTTnet.Extensions.TopicTemplate
|
|||||||
{
|
{
|
||||||
return topicTemplate.MatchesTopic(message.Topic, subtree);
|
return topicTemplate.MatchesTopic(message.Topic, subtree);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set the filter topic according to the template, with
|
/// Set the filter topic according to the template, with
|
||||||
/// template parameters substituted by a single-level
|
/// template parameters substituted by a single-level
|
||||||
@@ -119,7 +115,7 @@ namespace MQTTnet.Extensions.TopicTemplate
|
|||||||
{
|
{
|
||||||
return builder.WithTopic(subscribeTreeRoot ? topicTemplate.TopicTreeRootFilter : topicTemplate.TopicFilter);
|
return builder.WithTopic(subscribeTreeRoot ? topicTemplate.TopicTreeRootFilter : topicTemplate.TopicFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set the publication topic according to the topic template. The template
|
/// Set the publication topic according to the topic template. The template
|
||||||
/// must not have remaining (unset) parameters or contain wildcards.
|
/// must not have remaining (unset) parameters or contain wildcards.
|
||||||
@@ -143,7 +139,7 @@ namespace MQTTnet.Extensions.TopicTemplate
|
|||||||
{
|
{
|
||||||
throw new ArgumentException("topic templates must be parameter-less when sending " + topicTemplate.Template);
|
throw new ArgumentException("topic templates must be parameter-less when sending " + topicTemplate.Template);
|
||||||
}
|
}
|
||||||
|
|
||||||
MqttTopicValidator.ThrowIfInvalid(topicTemplate.Template);
|
MqttTopicValidator.ThrowIfInvalid(topicTemplate.Template);
|
||||||
return builder.WithTopic(topicTemplate.Template);
|
return builder.WithTopic(topicTemplate.Template);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using MQTTnet.Client;
|
using MQTTnet.Client;
|
||||||
using MQTTnet.Diagnostics;
|
using MQTTnet.Diagnostics;
|
||||||
@@ -678,9 +677,9 @@ namespace MQTTnet.Tests.Clients.ManagedMqttClient
|
|||||||
{
|
{
|
||||||
testEnvironment.IgnoreClientLogErrors = true;
|
testEnvironment.IgnoreClientLogErrors = true;
|
||||||
bool reject = true;
|
bool reject = true;
|
||||||
var receivedOnServer = new TaskCompletionSource();
|
var receivedOnServer = new TaskCompletionSource<object>();
|
||||||
managedClient.ApplicationMessageProcessedAsync += e => Task.FromResult(reject &= e.Exception is null);
|
managedClient.ApplicationMessageProcessedAsync += e => Task.FromResult(reject &= e.Exception is null);
|
||||||
testEnvironment.Server.InterceptingInboundPacketAsync += e =>
|
testEnvironment.Server.InterceptingInboundPacketAsync += e =>
|
||||||
{
|
{
|
||||||
if (e.Packet is MqttPublishPacket)
|
if (e.Packet is MqttPublishPacket)
|
||||||
{
|
{
|
||||||
@@ -690,14 +689,14 @@ namespace MQTTnet.Tests.Clients.ManagedMqttClient
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
receivedOnServer.TrySetResult();
|
receivedOnServer.TrySetResult(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
await managedClient.EnqueueAsync(new MqttApplicationMessage { Topic = topic, Payload = new byte[] { 1 }, Retain = true, QualityOfServiceLevel = MqttQualityOfServiceLevel.AtLeastOnce });
|
await managedClient.EnqueueAsync(new MqttApplicationMessage { Topic = topic, PayloadSegment = new ArraySegment<byte>(new byte[] { 1 }), Retain = true, QualityOfServiceLevel = MqttQualityOfServiceLevel.AtLeastOnce });
|
||||||
|
|
||||||
var timeoutTask = Task.Delay(testTimeout);
|
var timeoutTask = Task.Delay(testTimeout);
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ namespace MQTTnet.Server
|
|||||||
while (!cancellationToken.IsCancellationRequested)
|
while (!cancellationToken.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
TryProcessClients();
|
TryProcessClients();
|
||||||
Sleep(_options.KeepAliveMonitorInterval);
|
Sleep(_options.KeepAliveOptions.MonitorInterval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
|
|||||||
Reference in New Issue
Block a user