-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtwo_party_test_simple.cpp
More file actions
54 lines (47 loc) · 1.5 KB
/
two_party_test_simple.cpp
File metadata and controls
54 lines (47 loc) · 1.5 KB
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
50
51
52
53
54
#include <string>
#include "node.h"
#include "node_utils.h"
#include <iostream>
int main(int argc, char** argv) {
OPENFHE_DEBUG_FLAG(debug_flag_val); // set to true to turn on DEBUG() statements
CommParams params;
// char optstring[] = "i:p:l:n:W:h";
if (!processInputParams(argc, argv, params)) {
usage(argv[0]);
exit(EXIT_FAILURE);
}
// Demarcate where the tests start
NodeImpl mynode;
mynode.Register(params); // initiate and add nodes
mynode.Start();
int numToSend = 50; //
if (params.NodeName == "Server") { // The broadcaster
std::string sendToNode = "Client1";
message_format Msgsent;
Msgsent.NodeName = params.NodeName;
Msgsent.msgType = "HelloMsg";
std::cout << "DEMARCATE START" << std::endl;
for (int i = 0; i < numToSend; i++) {
Msgsent.Data = "Msg:" + std::to_string(i);
mynode.sendMsg(sendToNode, Msgsent);
}
std::cout << "DEMARCATE END" << std::endl;
} else {
std::string getfromNode = "Server";
int seenMsgs = 0;
std::cout << "DEMARCATE START" << std::endl;
while (seenMsgs < numToSend) {
auto reply1 = mynode.getMsg(getfromNode);
while (!reply1.acknowledgement) {
reply1 = mynode.getMsg(getfromNode);
}
auto toCout = "Got message: " + std::to_string(seenMsgs);
std::cout << toCout << std::endl;
seenMsgs += 1;
}
std::cout << "DEMARCATE END" << std::endl;
}
OPENFHE_DEBUG("End");
mynode.Stop(); // exception thrown if not stopped
return 0;
}