From da65d125312cc8f55ef0fcbd126f01dbdc889911 Mon Sep 17 00:00:00 2001 From: rsecrist Date: Thu, 22 Feb 2024 13:41:16 -0700 Subject: [PATCH 1/2] add a tick/keepalive option --- bin/wscat | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/wscat b/bin/wscat index 026a3c2..143b68e 100755 --- a/bin/wscat +++ b/bin/wscat @@ -158,6 +158,7 @@ program 'print a notification when a ping or pong is received' ) .option('-s, --subprotocol ', 'optional subprotocol', collect, []) + .option('-t, --tick ', 'send a message every 5 seconds') .option('-w, --wait ', 'wait given seconds after executing command') .option('-x, --execute ', 'execute command after connecting') .parse(process.argv); @@ -261,6 +262,9 @@ if (programOptions.listen) { if (programOptions.proxy) options.agent = new HttpsProxyAgent(programOptions.proxy); if (programOptions.location) options.followRedirects = true; + if (programOptions.tick) setInterval(function() { + ws.send(programOptions.tick); + }, 5000); options.maxRedirects = programOptions.maxRedirects; options.headers = headers; From 30bf002417c915e93636d972b68891300c79ab16 Mon Sep 17 00:00:00 2001 From: rsecrist Date: Thu, 22 Feb 2024 19:40:34 -0700 Subject: [PATCH 2/2] update readme with tick option --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 435cc33..6ab2203 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ Options: -p, --protocol optional protocol version -P, --show-ping-pong print a notification when a ping or pong is received -s, --subprotocol optional subprotocol (default: []) + -t, --tick send a message every 5 seconds -w, --wait wait given seconds after executing command -x, --execute execute command after connecting -h, --help display help for command