Moved undeliveredMessageInterceptor to local variable to avoid threading issues.

This commit is contained in:
SeppPenner
2020-06-11 12:41:48 +02:00
parent a407fc381b
commit 257211fc7a
@@ -238,12 +238,14 @@ namespace MQTTnet.Server
if (deliveryCount == 0)
{
if (_options.UndeliveredMessageInterceptor == null)
var undeliveredMessageInterceptor = _options.UndeliveredMessageInterceptor;
if (undeliveredMessageInterceptor == null)
{
return;
}
await _options.UndeliveredMessageInterceptor.InterceptApplicationMessagePublishAsync(new MqttApplicationMessageInterceptorContext(sender?.ClientId, sender?.Session?.Items, applicationMessage));
await undeliveredMessageInterceptor.InterceptApplicationMessagePublishAsync(new MqttApplicationMessageInterceptorContext(sender?.ClientId, sender?.Session?.Items, applicationMessage));
}
}
catch (OperationCanceledException)