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

Fix #1524 and #1525. #1526

Closed
wants to merge 1 commit into from
Closed

Fix #1524 and #1525. #1526

wants to merge 1 commit into from

Conversation

redboltz
Copy link
Contributor

topicAliasMaximum for receiving is designed as setting by MqttClient
option, not setting by CONNECT property.
And it is automatically used as CONNECT property.

However, the document said topicAliasMaximum is set by CONNECT
property.
It is bad so I fixed it.

In addition, corresponding typescript definitions are fixed.

`topicAliasMaximum` for receiving is designed as setting by MqttClient
option, not setting by CONNECT property.
And it is automatically used as CONNECT property.

However, the document said `topicAliasMaximum` is set by CONNECT
property.
It is bad so I fixed it.

In addition, corresponding typescript definitions are fixed.
@codecov
Copy link

codecov bot commented Aug 16, 2022

Codecov Report

Patch coverage: 90.90% and project coverage change: -0.04 ⚠️

Comparison is base (aa49aaf) 86.21% compared to head (c64bd8a) 86.18%.

❗ Current head c64bd8a differs from pull request most recent head c07ede6. Consider uploading reports for the commit c07ede6 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1526      +/-   ##
==========================================
- Coverage   86.21%   86.18%   -0.04%     
==========================================
  Files          12       13       +1     
  Lines        1306     1310       +4     
==========================================
+ Hits         1126     1129       +3     
- Misses        180      181       +1     
Impacted Files Coverage Δ
lib/client.js 90.87% <80.00%> (-0.11%) ⬇️
lib/connect/index.js 89.02% <100.00%> (+0.13%) ⬆️
lib/connect/ws.js 35.83% <100.00%> (ø)
lib/is-browser.js 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@redboltz
Copy link
Contributor Author

I have implemented TopicAlias functionality as #1301.
At that time, TopicAliasMaximum property has already been implemented but it didn't work as TopicAlias, just set CONNECT property.
So I implemented TopicAlias functionaliy. It includes auto assign and auto map Topic Alias functionalities.
I added the document to the following options:

  • autoUseTopicAlias: enabling automatic Topic Alias using functionality
  • autoAssignTopicAlias: enabling automatic Topic Alias assign functionality

But I forgot to move topicAliasMaximum from propertiy to option.
This PR do that.

TopicAliasMaximum property of CONNECT packet is designed as generated by options. So the document is now matched to the design.

In addtion, typescript typedefinition is fixed.

ogis-yamazaki added a commit to ogis-yamazaki/MQTT.js that referenced this pull request Aug 24, 2022
ogis-yamazaki added a commit to ogis-yamazaki/MQTT.js that referenced this pull request Aug 25, 2022
@robertsLando
Copy link
Member

@redboltz Thanks for this PR. Unfortunately I found this after merging #1519. Could you fix this so it also revert that?

@robertsLando
Copy link
Member

robertsLando commented Jun 23, 2023

By looking at the code at:

connectPacket.properties.topicAliasMaximum = this.topicAliasRecv.max

If you checked few lines above the packet is created by cloning options:

const connectPacket = Object.create(this.options)

Seems that it's correct to have it under properties otherwise that property would not be picked up by mqtt-packet: https://github.com/mqttjs/mqtt-packet/blob/master/types/index.d.ts#L69

Also by looking at the tests regarding topicAliasMaximum I found there where some tests using it at root in option and others having it inside options.properties, see #1612.

If you wish to change this you should also fix the connect packet that actually clones the options like I said before, BTW I suggest to keep it like it is now

@redboltz
Copy link
Contributor Author

Thanks, I will catch up the current main branch, and then I would update the PR.

@redboltz
Copy link
Contributor Author

Now, I noticed that adding the following options for typescript is implemented and merged as #1525

  autoUseTopicAlias?: boolean
  autoAssignTopicAlias?: boolean

Also I belive that I understand the design policy for MQTTClient design policy.

  1. options.properties is used for not only CONNECT packet property but also MQTTClient configuration.
  2. If a configuration is corresponding to CONNECT packet property (e.g.topicAliasMaximum), then the configuration should be located on options.property, otherwise (e.g. autoUseTopicAlias) should be located on options directly.

I think that if the poliy is explicitly stated somewhere, it would help other contributors.

So I close the PR.

@redboltz redboltz closed this Jun 24, 2023
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.

2 participants