Skip to content

Commit 8555c77

Browse files
committed
Place topic before payload
1 parent 47b07b2 commit 8555c77

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

include/aws/iot/MqttRequestResponseClient.h

+17-17
Original file line numberDiff line numberDiff line change
@@ -121,53 +121,53 @@ namespace Aws
121121
/**
122122
* Default constructor
123123
*/
124-
IncomingPublishEvent() : m_payload(), m_topic()
124+
IncomingPublishEvent() : m_topic(), m_payload()
125125
{
126-
AWS_ZERO_STRUCT(m_payload);
127126
AWS_ZERO_STRUCT(m_topic);
127+
AWS_ZERO_STRUCT(m_payload);
128128
}
129129

130130
/**
131-
* Sets the message payload associated with this event. The event does not own this payload.
131+
* Sets the message response topic associated with this event. The event does not own this topic.
132132
*
133-
* @param payload the message payload associated with this event
133+
* @param topic the message response topic associated with this event
134134
* @return reference to this
135135
*/
136-
IncomingPublishEvent &WithPayload(Aws::Crt::ByteCursor payload)
136+
IncomingPublishEvent &WithTopic(Aws::Crt::ByteCursor topic)
137137
{
138-
m_payload = payload;
138+
m_topic = topic;
139139
return *this;
140140
}
141141

142142
/**
143-
* Sets the message response topic associated with this event. The event does not own this topic.
143+
* Sets the message payload associated with this event. The event does not own this payload.
144144
*
145-
* @param topic the message response topic associated with this event
145+
* @param payload the message payload associated with this event
146146
* @return reference to this
147147
*/
148-
IncomingPublishEvent &WithTopic(Aws::Crt::ByteCursor topic)
148+
IncomingPublishEvent &WithPayload(Aws::Crt::ByteCursor payload)
149149
{
150-
m_topic = topic;
150+
m_payload = payload;
151151
return *this;
152152
}
153153

154154
/**
155-
* Gets the message payload associated with this event.
155+
* Gets the message response topic associated with this event.
156156
*
157-
* @return the message payload associated with this event
157+
* @return the message response topic associated with this event
158158
*/
159-
Aws::Crt::ByteCursor GetPayload() const { return m_payload; }
159+
Aws::Crt::ByteCursor GetTopic() const { return m_topic; }
160160

161161
/**
162-
* Gets the message response topic associated with this event.
162+
* Gets the message payload associated with this event.
163163
*
164-
* @return the message response topic associated with this event
164+
* @return the message payload associated with this event
165165
*/
166-
Aws::Crt::ByteCursor GetTopic() const { return m_topic; }
166+
Aws::Crt::ByteCursor GetPayload() const { return m_payload; }
167167

168168
private:
169-
Aws::Crt::ByteCursor m_payload;
170169
Aws::Crt::ByteCursor m_topic;
170+
Aws::Crt::ByteCursor m_payload;
171171
};
172172

173173
/**

tests/MqttRequestResponse.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ struct ResponseTracker
4242

4343
struct TestPublishEvent
4444
{
45-
Aws::Crt::String payload;
4645
Aws::Crt::String topic;
46+
Aws::Crt::String payload;
4747
};
4848

4949
struct TestState
@@ -174,13 +174,13 @@ static void s_onIncomingPublishEvent(Aws::Iot::RequestResponse::IncomingPublishE
174174
{
175175
std::unique_lock<std::mutex> lock(state->lock);
176176

177-
auto payloadCursor = event.GetPayload();
178-
Aws::Crt::String payloadAsString((const char *)payloadCursor.ptr, payloadCursor.len);
179-
180177
auto topicCursor = event.GetTopic();
181178
Aws::Crt::String topicAsString((const char *)topicCursor.ptr, topicCursor.len);
182179

183-
state->incomingPublishEvents.push_back({std::move(payloadAsString), std::move(topicAsString)});
180+
auto payloadCursor = event.GetPayload();
181+
Aws::Crt::String payloadAsString((const char *)payloadCursor.ptr, payloadCursor.len);
182+
183+
state->incomingPublishEvents.push_back({std::move(topicAsString), std::move(payloadAsString)});
184184
}
185185
state->signal.notify_one();
186186
}
@@ -1088,7 +1088,7 @@ static int s_doShadowUpdatedStreamIncomingPublishTest(Aws::Crt::Allocator *alloc
10881088
s_waitForIncomingPublishWithPredicate(
10891089
&state,
10901090
[&uuid](const TestPublishEvent &publishEvent)
1091-
{ return publishEvent.payload == Aws::Crt::String(s_publishPayload) && publishEvent.topic == uuid; });
1091+
{ return publishEvent.topic == uuid && publishEvent.payload == Aws::Crt::String(s_publishPayload); });
10921092

10931093
return AWS_OP_SUCCESS;
10941094
}

0 commit comments

Comments
 (0)