代码拉取完成,页面将自动刷新
#include <signal.h>
#include <unistd.h>
#include <rapidjson/document.h>
#include <iostream>
#include "websocket_endpoint.h"
#include "trace_worker.h"
#include "JsonHelper.h"
void whenSigInt(int)
{
trace_stop();
printf("trace_stoptrace_stoptrace_stoptrace_stop\n");
exit(0);
}
int main(int argc, char* argv[])
{
signal(SIGSEGV, whenSigInt);
signal(SIGINT, whenSigInt);
signal(SIGABRT, whenSigInt);
trace_start("./1111.cpp", false);
if (argc != 3)
{
printf("ws-client openId cmd.json\n");
return -1;
}
CWsClient wsClient;
const std::string uri = std::string("ws://localhost:8000/") + argv[1];
if (wsClient.Connect(uri) == false)
{
printf("connect %s failed\n", uri.c_str());
return -1;
}
sleep(1);
std::ifstream ifs(argv[2]);
rapidjson::IStreamWrapper isw(ifs);
rapidjson::Document document;
if (document.ParseStream(isw).HasParseError())
{
printf("GetParseError %d\n", document.GetParseError());
return -1;
}
rapidjson::Value &cmdArraryValue = document;
for (int time=0; time<10000; ++time)
{
for (unsigned int cmdArraryIndex=0; cmdArraryIndex<cmdArraryValue.Size(); ++cmdArraryIndex)
{
const rapidjson::Value &cmdValue = cmdArraryValue[cmdArraryIndex];
const int &interval = cmdValue["interval"].GetInt();
const std::string &method = cmdValue["method"].GetString();
rapidjson::StringBuffer buffer;
wsClient.Send(method + ":" + CJsonHelper::toString(cmdValue["content"], buffer));
usleep(1000 * interval);
}
}
trace_stop();
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。