forked from kakaochatfriend/KakaoChatFriendAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathecho.cc
More file actions
39 lines (37 loc) · 1.01 KB
/
Copy pathecho.cc
File metadata and controls
39 lines (37 loc) · 1.01 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
#include <iostream>
#include "RepliceClient.hpp"
int main()
{
boost::asio::io_service io;
Replice::ClientPtr r(new Replice::Client(io, "localhost", "11111", "test", "test"));
r->add_message_handler("default", [=](const Replice::Type type, const mongo::BSONObj& msg) {
std::cout << "default handler recv : " << msg << std::endl;
switch(type)
{
case Replice::Type::ADD:
{
mongo::BSONObjBuilder res_builder;
r->makeResponse(msg, res_builder);
res_builder << "message" << "hihi";
bson::bo res = res_builder.obj();
r->send(res);
std::cout << "default handler sent : " << res << std::endl;
}
break;
case Replice::Type::REQUEST:
{
mongo::BSONObjBuilder res_builder;
r->makeResponse(msg, res_builder);
res_builder << "message" << msg["message"];
bson::bo res = res_builder.obj();
r->send(res);
std::cout << "default handler sent : " << res << std::endl;
}
break;
case Replice::Type::RESULT:
return;
};
});
r->start(4);
r->join();
}