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

sending topic-id in puback message as per v1.2 spec #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions rsmb/src/MQTTSPacket.c
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ int MQTTSPacket_send_publish(Clients* client, MQTTS_Publish* pub)
}


int MQTTSPacket_send_puback(Clients* client, /*char* shortTopic, int topicId, */ int msgId, char returnCode)
int MQTTSPacket_send_puback(Clients* client, int topicId, int msgId, char returnCode)
{
MQTTS_PubAck packet;
char *buf, *ptr;
Expand All @@ -985,7 +985,7 @@ int MQTTSPacket_send_puback(Clients* client, /*char* shortTopic, int topicId, */
writeChar(&ptr, shortTopic[1]);
}
else */
writeInt(&ptr, 0); /* writeInt(&ptr, topicId); */
writeInt(&ptr, topicId); /* writeInt(&ptr, 0); */
writeInt(&ptr, msgId);
writeChar(&ptr, returnCode);

Expand Down
2 changes: 1 addition & 1 deletion rsmb/src/MQTTSPacket.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ int MQTTSPacket_send_pingResp(Clients* client);
int MQTTSPacket_send_willTopicResp(Clients* client);
int MQTTSPacket_send_willMsgResp(Clients* client);
int MQTTSPacket_send_regAck(Clients* client, int msgId, int topicId, char rc);
int MQTTSPacket_send_puback(Clients* client, int msgId, char returnCode);
int MQTTSPacket_send_puback(Clients* client, int topicId, int msgId, char returnCode);
int MQTTSPacket_send_pubrec(Clients* client, int msgId);
int MQTTSPacket_send_pubrel(Clients* client, int msgId);
int MQTTSPacket_send_pubcomp(Clients* client, int msgId);
Expand Down
9 changes: 7 additions & 2 deletions rsmb/src/Protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,9 @@ int Protocol_isClientQuiescing(Clients* client)
int Protocol_handlePublishes(Publish* publish, int sock, Clients* client, char* clientid)
{
int rc = TCPSOCKET_COMPLETE;
#if defined(MQTTS)
int topicId = 0;
#endif
#if !defined(SINGLE_LISTENER)
Listener* listener = NULL;
#endif
Expand Down Expand Up @@ -474,8 +477,10 @@ int Protocol_handlePublishes(Publish* publish, int sock, Clients* client, char*
{
/* send puback before processing the publications because a lot of return publications could fill up the socket buffer */
#if defined(MQTTS)
if (client->protocol == PROTOCOL_MQTTS)
rc = MQTTSPacket_send_puback(client, publish->msgId, MQTTS_RC_ACCEPTED);
if (client->protocol == PROTOCOL_MQTTS){
topicId = MQTTSProtocol_getRegisteredTopicId(client, publish->topic);
rc = MQTTSPacket_send_puback(client, topicId, publish->msgId, MQTTS_RC_ACCEPTED);
}
else
#endif
rc = MQTTPacket_send_puback(publish->msgId, sock, clientid);
Expand Down