// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Collections; namespace MQTTnet.Server; public sealed class InterceptingPublishEventArgs : EventArgs { public InterceptingPublishEventArgs(MqttApplicationMessage applicationMessage, string clientId, string userName, IDictionary sessionItems, CancellationToken cancellationToken) { ApplicationMessage = applicationMessage ?? throw new ArgumentNullException(nameof(applicationMessage)); CancellationToken = cancellationToken; ClientId = clientId ?? throw new ArgumentNullException(nameof(clientId)); UserName = userName; SessionItems = sessionItems ?? throw new ArgumentNullException(nameof(sessionItems)); } public MqttApplicationMessage ApplicationMessage { get; set; } /// /// Gets the cancellation token which can indicate that the client connection gets down. /// public CancellationToken CancellationToken { get; } /// /// Gets the client identifier. /// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues. /// public string ClientId { get; } public bool CloseConnection { get; set; } /// /// Gets or sets whether the publish should be processed internally. /// public bool ProcessPublish { get; set; } = true; /// /// Gets the response which will be sent to the client via the PUBACK etc. packets. /// public PublishResponse Response { get; } = new(); /// /// Gets or sets a key/value collection that can be used to share data within the scope of this session. /// public IDictionary SessionItems { get; } /// /// Gets the user name of the client. /// public string UserName { get; } }