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

Return one retained message #1659

Closed
michael-eckhart-woellkart opened this issue Jan 26, 2023 · 5 comments · Fixed by #1676
Closed

Return one retained message #1659

michael-eckhart-woellkart opened this issue Jan 26, 2023 · 5 comments · Fixed by #1676
Labels
feature-request New feature or request

Comments

@michael-eckhart-woellkart

Describe the feature request

Return one retained message

Which project is your feature request related to?

  • Server

Describe the solution you'd like

Implement new method which only return one method

@michael-eckhart-woellkart michael-eckhart-woellkart added the feature-request New feature or request label Jan 26, 2023
@michael-eckhart-woellkart
Copy link
Author

This would be done by:

MQTTnet\Server\Internal\MqttRetainedMessagesManager.cs

        public Task<MqttApplicationMessage> GetMessage(string topic)
        {
            lock (_messages)
            {
                if (!_messages.TryGetValue(topic, out var message))
                {
                    return Task.FromResult(message);
                }
                else
                {
                    return null;
                }
            }
        }

MQTTnet\Server\MqttServer.cs

        public Task<MqttApplicationMessage> GetRetainedMessageAsync(string topic)
        {
            ThrowIfNotStarted();
            return _retainedMessagesManager.GetMessage(topic);
        }

@chkr1011
Copy link
Collaborator

So you basically need an API which lets you get exactly one retained message instead of all?

@michael-eckhart-woellkart
Copy link
Author

So you basically need an API which lets you get exactly one retained message instead of all?

Correct :)

@chkr1011
Copy link
Collaborator

chkr1011 commented Feb 5, 2023

Please try the code from the branch attached to this ticket or try build 653 from the myget feed. If the code works please let me know. I will then merge the feature.

@michael-eckhart-woellkart
Copy link
Author

Work for me.

@chkr1011 chkr1011 linked a pull request Feb 15, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants