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

Optimize SendPacketAsync method for MQTTnet.AspNetCore #1582

Merged
merged 5 commits into from
Nov 28, 2022

Conversation

xljiulang
Copy link
Contributor

@dnfadmin
Copy link

dnfadmin commented Nov 24, 2022

CLA assistant check
All CLA requirements met.

@xljiulang
Copy link
Contributor Author

@chkr1011
I've added a readonly bool? _isOverWebSocket field, we keep using buffer.Json() when it's value is true or null.

var feature = connection.Features.Get<IHttpContextFeature>();
if (feature != null)
{
_isOverWebSocket = feature.HttpContext.WebSockets.IsWebSocketRequest;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiosity, there any chance that this will be not a web socket request?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, MqttConnectionHandler has two usage scenarios, UseMqtt and MapMqtt, for over tcp and over WebSocket.

@chkr1011
Copy link
Collaborator

Thank you for your contribution. Good work 👍

@chkr1011 chkr1011 merged commit 41df2ec into dotnet:master Nov 28, 2022
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

Successfully merging this pull request may close these issues.

3 participants