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
|
#include "../../../../cpp/wsWebsocketConnection.h"
#include <iostream>
#include <string>
const char* TOPIC = "wslink.communication.channel";
const char* SECRET = "wslink-secret";
const char* HOST = "127.0.0.1";
const char* PORT = "8080";
const char* TARGET = "/ws";
using std::cout;
using std::endl;
int main(int argc, char *argv[])
{
wsWebsocketConnection ws{SECRET};
ws.connect(HOST, PORT, TARGET);
ws.subscribe(TOPIC,
[](const json& json) -> void
{
cout << json["id"] << " -> " << json["result"] << endl;
});
std::string line;
while (std::cin >> line)
{
json args = { line.c_str() };
ws.send("wslink.say.hello", nullptr, &args);
}
json result = {};
ws.send("wslink.stop.talking", &result);
return EXIT_SUCCESS;
}
|