mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-16 01:51:45 +00:00
Extend DDS Example to use command interface
This commit is contained in:
committed by
Mohammad Al-Turany
parent
837e035457
commit
c9c881c33c
44
examples/MQ/3-dds/runDDSCommandUI.cxx
Normal file
44
examples/MQ/3-dds/runDDSCommandUI.cxx
Normal file
@@ -0,0 +1,44 @@
|
||||
// DDS
|
||||
#include "CustomCmd.h"
|
||||
// STD
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
#include <sstream>
|
||||
#include <thread>
|
||||
#include <atomic>
|
||||
|
||||
using namespace std;
|
||||
using namespace dds;
|
||||
using namespace custom_cmd;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
try
|
||||
{
|
||||
CCustomCmd ddsCustomCmd;
|
||||
|
||||
ddsCustomCmd.subscribeCmd([](const string& command, const string& condition, uint64_t senderId)
|
||||
{
|
||||
cout << "Received: \"" << command << "\"" << endl;
|
||||
});
|
||||
|
||||
while (true)
|
||||
{
|
||||
int result = ddsCustomCmd.sendCmd("check-state", "");
|
||||
|
||||
if (result == 1)
|
||||
{
|
||||
cerr << "Error sending custom command" << endl;
|
||||
}
|
||||
|
||||
this_thread::sleep_for(chrono::seconds(1));
|
||||
}
|
||||
}
|
||||
catch (exception& _e)
|
||||
{
|
||||
cerr << "Error: " << _e.what() << endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Reference in New Issue
Block a user