Skip to content

Commit

Permalink
Different approach to one constructor
Browse files Browse the repository at this point in the history
The saving sessions should happen automatically now.
  • Loading branch information
halfgaar committed Nov 9, 2024
1 parent 55594af commit a8501bd
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion FlashMQTests/plugintests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ void MainTests::testFailedAsyncClientCrashOnSession()
FlashMQTestClient &second_client = clients.back();

Publish pub("sdf", "wer", 2);
MqttPacket pubPack(second_client.getClient()->getProtocolVersion(), pub, 0);
MqttPacket pubPack(second_client.getClient()->getProtocolVersion(), pub);
if (pub.qos > 0)
pubPack.setPacketId(3);
second_client.getClient()->writeMqttPacketAndBlameThisClient(pubPack);
Expand Down
6 changes: 3 additions & 3 deletions FlashMQTests/tst_maintests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ void MainTests::testPacketInt16Parse()
for (const uint16_t id : tests)
{
Publish pub("hallo", "content", 1);
MqttPacket packet(ProtocolVersion::Mqtt311, pub, 0);
MqttPacket packet(ProtocolVersion::Mqtt311, pub);
packet.setPacketId(id);
packet.pos -= 2;
uint16_t idParsed = packet.readTwoBytesToUInt16();
Expand Down Expand Up @@ -978,7 +978,7 @@ void MainTests::testSavingSessions()

std::shared_ptr<Session> c1ses = c1->getSession();
c1.reset();
MqttPacket publishPacket(ProtocolVersion::Mqtt5, publish, 1); // TODO: subscription identifier, what to do here?
MqttPacket publishPacket(ProtocolVersion::Mqtt5, publish);
PublishCopyFactory fac(&publishPacket);
c1ses->writePacket(fac, 1, false, publishPacket.getPublishData().subscriptionIdentifier); // TODO: subscription identifier? What to do / test?

Expand Down Expand Up @@ -1102,7 +1102,7 @@ void MainTests::testParsePacketHelper(const std::string &topic, uint8_t from_qos
const std::string payloadOne = getSecureRandomString(len);
Publish pubOne(topic, payloadOne, from_qos);
pubOne.retain = retain;
MqttPacket stagingPacketOne(ProtocolVersion::Mqtt311, pubOne, 0);
MqttPacket stagingPacketOne(ProtocolVersion::Mqtt311, pubOne);
if (from_qos > 0)
stagingPacketOne.setPacketId(pack_id);
CirBuf stagingBufOne(1024);
Expand Down
2 changes: 1 addition & 1 deletion flashmqtestclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ void FlashMQTestClient::publish(Publish &pub)

const uint16_t packet_id = 77;

MqttPacket pubPack(client->getProtocolVersion(), pub, 0);
MqttPacket pubPack(client->getProtocolVersion(), pub);
if (pub.qos > 0)
pubPack.setPacketId(packet_id);
client->writeMqttPacketAndBlameThisClient(pubPack);
Expand Down
4 changes: 2 additions & 2 deletions mqttpacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ MqttPacket::MqttPacket(const UnsubAck &unsubAck) :
calculateRemainingLength();
}

MqttPacket::MqttPacket(const ProtocolVersion protocolVersion, const Publish &_publish, const uint32_t subscriptionIdentifier) :
MqttPacket(protocolVersion, _publish, _publish.qos, _publish.topicAlias, _publish.skipTopic, subscriptionIdentifier)
MqttPacket::MqttPacket(const ProtocolVersion protocolVersion, const Publish &_publish) :
MqttPacket(protocolVersion, _publish, _publish.qos, _publish.topicAlias, _publish.skipTopic, _publish.subscriptionIdentifier)
{

}
Expand Down
2 changes: 1 addition & 1 deletion mqttpacket.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class MqttPacket
MqttPacket(const ConnAck &connAck);
MqttPacket(const SubAck &subAck);
MqttPacket(const UnsubAck &unsubAck);
MqttPacket(const ProtocolVersion protocolVersion, const Publish &_publish, const uint32_t subscriptionIdentifier);
MqttPacket(const ProtocolVersion protocolVersion, const Publish &_publish);
MqttPacket(const ProtocolVersion protocolVersion, const Publish &_publish, const uint8_t _qos, const uint16_t _topic_alias,
const bool _skip_topic, const uint32_t subscriptionIdentifier);
MqttPacket(const PubResponse &pubAck);
Expand Down
2 changes: 1 addition & 1 deletion retainedmessagesdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void RetainedMessagesDB::saveData(const std::vector<RetainedMessage> &messages)
logger->logf(LOG_DEBUG, "Saving retained message for topic '%s' QoS %d, age %d seconds.", rm.publish.topic.c_str(), rm.publish.qos, rm.publish.getAge());

Publish pcopy(rm.publish);
MqttPacket pack(ProtocolVersion::Mqtt5, pcopy, 0); // TODO: subscription identifier
MqttPacket pack(ProtocolVersion::Mqtt5, pcopy);

// Dummy, to please the parser on reading.
if (pcopy.qos > 0)
Expand Down
4 changes: 2 additions & 2 deletions sessionsandsubscriptionsdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ void SessionsAndSubscriptionsDB::saveData(const std::vector<std::shared_ptr<Sess

logger->logf(LOG_DEBUG, "Saving QoS %d message for topic '%s'.", pub.qos, pub.topic.c_str());

MqttPacket pack(ProtocolVersion::Mqtt5, pub, 0); // TODO: subscription identifier
MqttPacket pack(ProtocolVersion::Mqtt5, pub);
pack.setPacketId(p.getPacketId());
const uint32_t packSize = pack.getSizeIncludingNonPresentHeader();
cirbuf.reset();
Expand Down Expand Up @@ -368,7 +368,7 @@ void SessionsAndSubscriptionsDB::saveData(const std::vector<std::shared_ptr<Sess

if (hasWillThatShouldSurviveRestart)
{
MqttPacket willpacket(ProtocolVersion::Mqtt5, *will, 0); // TODO subscription identifier
MqttPacket willpacket(ProtocolVersion::Mqtt5, *will);

// Dummy, to please the parser on reading.
if (will->qos > 0)
Expand Down

0 comments on commit a8501bd

Please sign in to comment.