(ws) ws connect gains a new option to set the interval at which to send pings
This commit is contained in:
@@ -112,6 +112,7 @@ int main(int argc, char** argv)
|
||||
int count = 1;
|
||||
uint32_t maxWaitBetweenReconnectionRetries;
|
||||
size_t maxQueueSize = 100;
|
||||
int pingIntervalSecs = 30;
|
||||
|
||||
auto addTLSOptions = [&tlsOptions, &verifyNone](CLI::App* app) {
|
||||
app->add_option(
|
||||
@@ -170,6 +171,9 @@ int main(int argc, char** argv)
|
||||
connectApp->add_option("--max_wait",
|
||||
maxWaitBetweenReconnectionRetries,
|
||||
"Max Wait Time between reconnection retries");
|
||||
connectApp->add_option("--ping_interval",
|
||||
pingIntervalSecs,
|
||||
"Interval between sending pings");
|
||||
connectApp->add_option("--subprotocol", subprotocol, "Subprotocol");
|
||||
addTLSOptions(connectApp);
|
||||
|
||||
@@ -389,7 +393,8 @@ int main(int argc, char** argv)
|
||||
binaryMode,
|
||||
maxWaitBetweenReconnectionRetries,
|
||||
tlsOptions,
|
||||
subprotocol);
|
||||
subprotocol,
|
||||
pingIntervalSecs);
|
||||
}
|
||||
else if (app.got_subcommand("chat"))
|
||||
{
|
||||
|
3
ws/ws.h
3
ws/ws.h
@@ -50,7 +50,8 @@ namespace ix
|
||||
bool binaryMode,
|
||||
uint32_t maxWaitBetweenReconnectionRetries,
|
||||
const ix::SocketTLSOptions& tlsOptions,
|
||||
const std::string& subprotocol);
|
||||
const std::string& subprotocol,
|
||||
int pingIntervalSecs);
|
||||
|
||||
int ws_receive_main(const std::string& url,
|
||||
bool enablePerMessageDeflate,
|
||||
|
@@ -24,7 +24,8 @@ namespace ix
|
||||
bool binaryMode,
|
||||
uint32_t maxWaitBetweenReconnectionRetries,
|
||||
const ix::SocketTLSOptions& tlsOptions,
|
||||
const std::string& subprotocol);
|
||||
const std::string& subprotocol,
|
||||
int pingIntervalSecs);
|
||||
|
||||
void subscribe(const std::string& channel);
|
||||
void start();
|
||||
@@ -61,7 +62,8 @@ namespace ix
|
||||
bool binaryMode,
|
||||
uint32_t maxWaitBetweenReconnectionRetries,
|
||||
const ix::SocketTLSOptions& tlsOptions,
|
||||
const std::string& subprotocol)
|
||||
const std::string& subprotocol,
|
||||
int pingIntervalSecs)
|
||||
: _url(url)
|
||||
, _disablePerMessageDeflate(disablePerMessageDeflate)
|
||||
, _binaryMode(binaryMode)
|
||||
@@ -74,6 +76,7 @@ namespace ix
|
||||
}
|
||||
_webSocket.setMaxWaitBetweenReconnectionRetries(maxWaitBetweenReconnectionRetries);
|
||||
_webSocket.setTLSOptions(tlsOptions);
|
||||
_webSocket.setPingInterval(pingIntervalSecs);
|
||||
|
||||
_headers = parseHeaders(headers);
|
||||
|
||||
@@ -223,7 +226,8 @@ namespace ix
|
||||
bool binaryMode,
|
||||
uint32_t maxWaitBetweenReconnectionRetries,
|
||||
const ix::SocketTLSOptions& tlsOptions,
|
||||
const std::string& subprotocol)
|
||||
const std::string& subprotocol,
|
||||
int pingIntervalSecs)
|
||||
{
|
||||
std::cout << "Type Ctrl-D to exit prompt..." << std::endl;
|
||||
WebSocketConnect webSocketChat(url,
|
||||
@@ -233,7 +237,8 @@ namespace ix
|
||||
binaryMode,
|
||||
maxWaitBetweenReconnectionRetries,
|
||||
tlsOptions,
|
||||
subprotocol);
|
||||
subprotocol,
|
||||
pingIntervalSecs);
|
||||
webSocketChat.start();
|
||||
|
||||
while (true)
|
||||
|
Reference in New Issue
Block a user