(ws) Add a new ws sub-command, echo_client. This command send a message to an echo server, and send back to a server whatever message it does receive. When connecting to a local ws echo_server, on my MacBook Pro 2015 I can send/receive around 30,000 messages per second. (cf #235)
This commit is contained in:
23
ws/ws.cpp
23
ws/ws.cpp
@ -125,6 +125,7 @@ int main(int argc, char** argv)
|
||||
std::string logfile;
|
||||
std::string scriptPath;
|
||||
std::string republishChannel;
|
||||
std::string sendMsg("hello world");
|
||||
ix::SocketTLSOptions tlsOptions;
|
||||
ix::CobraConfig cobraConfig;
|
||||
ix::CobraBotConfig cobraBotConfig;
|
||||
@ -243,6 +244,18 @@ int main(int argc, char** argv)
|
||||
connectApp->add_option("--subprotocol", subprotocol, "Subprotocol");
|
||||
addTLSOptions(connectApp);
|
||||
|
||||
CLI::App* echoClientApp =
|
||||
app.add_subcommand("echo_client", "Echo messages sent by a remote server");
|
||||
echoClientApp->fallthrough();
|
||||
echoClientApp->add_option("url", url, "Connection url")->required();
|
||||
echoClientApp->add_flag("-x", disablePerMessageDeflate, "Disable per message deflate");
|
||||
echoClientApp->add_flag("-b", binaryMode, "Send in binary mode");
|
||||
echoClientApp->add_option(
|
||||
"--ping_interval", pingIntervalSecs, "Interval between sending pings");
|
||||
echoClientApp->add_option("--subprotocol", subprotocol, "Subprotocol");
|
||||
echoClientApp->add_option("--send_msg", sendMsg, "Send message");
|
||||
addTLSOptions(echoClientApp);
|
||||
|
||||
CLI::App* chatApp = app.add_subcommand("chat", "Group chat");
|
||||
chatApp->fallthrough();
|
||||
chatApp->add_option("url", url, "Connection url")->required();
|
||||
@ -504,6 +517,16 @@ int main(int argc, char** argv)
|
||||
subprotocol,
|
||||
pingIntervalSecs);
|
||||
}
|
||||
else if (app.got_subcommand("echo_client"))
|
||||
{
|
||||
ret = ix::ws_echo_client(url,
|
||||
disablePerMessageDeflate,
|
||||
binaryMode,
|
||||
tlsOptions,
|
||||
subprotocol,
|
||||
pingIntervalSecs,
|
||||
sendMsg);
|
||||
}
|
||||
else if (app.got_subcommand("echo_server"))
|
||||
{
|
||||
ret = ix::ws_echo_server_main(
|
||||
|
Reference in New Issue
Block a user