forked from mozilla-services/powerhose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathecho_worker.cpp
48 lines (33 loc) · 1.14 KB
/
echo_worker.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
#include "Worker.h"
#include <iostream>
#include <sstream>
class SquareWorker: public Worker {
protected:
void execute(::std::vector< ::std::string>* vreq, ::std::vector< ::std::string>* vres);
public:
SquareWorker(const char* receiverChannel, const char* endPoint);
};
SquareWorker::SquareWorker(const char* receiverChannel, const char* endPoint) : Worker(receiverChannel, endPoint) {
//
};
void SquareWorker::execute(::std::vector< ::std::string>* vreq, ::std::vector< ::std::string>* vres) {
int value;
::std::string number = vreq->at(2);
::std::stringstream ss(number);
ss >> value;
value *= value;
::std::stringstream out;
out << value;
vres->push_back(out.str());
}
int main(int argc, const char* const argv[]) {
const char* receiver = argv[1]; //"ipc://worker-cpp.ipc";
const char* endpoint = argv[2]; // "ipc:///tmp/master-routing.ipc";
::std::cout << receiver << ::std::endl;
::std::cout << endpoint << ::std::endl;
::std::cout << "Creating a worker" << ::std::endl;
SquareWorker worker(receiver, endpoint);
::std::cout << "Let's run it" << ::std::endl;
worker.run();
return 1;
}