Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add license check to Intercepting Publish on server #2099

Closed
dgxhubbard opened this issue Oct 29, 2024 · 4 comments
Closed

Add license check to Intercepting Publish on server #2099

dgxhubbard opened this issue Oct 29, 2024 · 4 comments

Comments

@dgxhubbard
Copy link

I would like to add a license check to InterceptingPublishAsync and if the license has not been entered then reject publish to
subscribers if license is not valid. First is InterceptingPublishAsync the right place to do this, second how to tell publisher that
license needs to be entered.

@dgxhubbard
Copy link
Author

I think what I need is in this article https://github.com/dotnet/MQTTnet/wiki/Server#intercepting-application-messages

@SeppPenner
Copy link
Collaborator

You can check https://github.com/dotnet/MQTTnet/blob/master/Samples/Server/Server_Intercepting_Samples.cs as the Wiki is for version 3 only.

  1. Yes, it is the right place.
  2. You need to set a property of the eventArgs to true. Not sure how it's called though. Something like this:

E.g.

public void InterceptPublishAsync (PublishEventArgs args)
{
    var someLicenseCheck = true;
    if (!someLicenseCheck)
    {
        args.Publish = false;
    }
}

@dgxhubbard
Copy link
Author

Thank you. That worked perfectly.

@SeppPenner
Copy link
Collaborator

Just for reference, it's InterceptingPublishEventArgs and ProcessPublish = false. Check out

public bool ProcessPublish { get; set; } = true;
.

I guess, this can be closed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants