Closed jpwsutton closed 6 years ago
Topic alias is not just enabled or disabled. The client gives the server the max value of a topic alias. The server can use topic alias 1 to max and any other value is a protocol error. The server is not required to send a topic alias even if the client has requested the use of topic alias. Note also that the topic alias max is a separate value in the two directions. The server sends the client a topic alias max on CONNACK.
One more thing, when a message arrives from the server with a topic alias but with a zero length topic name, the messageArraived() callback is being sent a zero length string for the topic argument, and not the saved topic name based on the topic alias.
If the client has not enabled topic aliases, but receives a message with a topic alias set, the message will just 'disappear' and not get sent to the callback. We need to throw an error and also pass the message through if we have a global callback.