-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcommand-sender.cpp
49 lines (36 loc) · 1001 Bytes
/
command-sender.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "interface.h"
//#include <iostream>
//#include <unistd.h>
//#include <sstream>
//#include <json/json.h>
using namespace Chaos;
CommandSender::CommandSender() {
// printf("Constructing CommandSender()\n");
const std::string endpoint = "tcp://localhost:5556";
// initialize the 0MQ context
//zmqpp::context context;
// generate a pull socket
zmqpp::socket_type type = zmqpp::socket_type::request;
socket = new zmqpp::socket(context, type);
// bind to the socket
// socket->bind(endpoint);
socket->connect(endpoint);
// printf("Done building CommandSender()\n");
}
CommandSender::~CommandSender() {
}
//void CommandSender::doAction() {
//
// pause();
//}
bool CommandSender::sendMessage(std::string message) {
// printf("sendMessage from CommandSender...\n");
socket->send( message.c_str() );
zmqpp::message msg;
// decompose the message
socket->receive(msg); // Blocking
msg >> reply;
// printf("sendMessage from CommandSender DONE!\n");
// resume();
return true;
}