Skip to content

Commit

Permalink
Update MQTT
Browse files Browse the repository at this point in the history
  • Loading branch information
Lecrapouille committed Nov 2, 2023
1 parent 8608c7b commit 7ea4b8b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/PetriEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ void PetriEditor::onConnected(int /*rc*/)
std::cout << "Petri net editor " << pid << " connected to MQTT broker"
<< std::endl;

unsubscribe(m_mqtt_topic);
if (!m_mqtt_topic.empty())
{
unsubscribe(m_mqtt_topic);
}
m_mqtt_topic = "pneditor-" + pid + "/" + m_petri_net.name();
std::string message("\nYou can publish your MQTT commands to the Petri net editor ");
m_message_bar.append(message + " the topic '" + m_mqtt_topic + "'");
Expand All @@ -190,7 +193,7 @@ void PetriEditor::onConnected(int /*rc*/)
// TBD: topic "editor/petri.json/P1" and message "=4" or "+2" or "-1"
// topic "editor/petri.json/T1" and message "1" or "0".
// "editor/petri.json and message "T1:T2;T3"
void PetriEditor::onMessageReceived(const struct mosquitto_message& msg)
void PetriEditor::onMessageReceived(MQTT::Message const& msg)
{
const char* payload = static_cast<char*>(msg.payload);
if (payload[0] == 'T')
Expand Down
2 changes: 1 addition & 1 deletion src/PetriEditor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ void renderScene(sf::RenderTexture&);
//! mouse click on transitions to fire them or increment the number of tokens
//! in a place.
//--------------------------------------------------------------------------
virtual void onMessageReceived(const struct mosquitto_message& message) override;
virtual void onMessageReceived(MQTT::Message const& message) override;

private: // Derived from Application::GUI

Expand Down

0 comments on commit 7ea4b8b

Please sign in to comment.