eliihen / wsta

A CLI development tool for WebSocket APIs
GNU General Public License v3.0
632 stars 19 forks source link

Need customizable ping. #17

Closed ZoomyCat closed 7 years ago

ZoomyCat commented 7 years ago

I'm planning on using your tool to automate connection to the PubSub system that twitch uses.

It requires the pings be sent as '{"type": "PING"}' and through the standard -p system I do not see a responce pong for a ping with this flag set.

Here is what I get by default and I am sure this is expected behavior for you:

$ wsta -e -p 10  wss://pubsub-edge.twitch.tv
Connected to wss://pubsub-edge.twitch.tv
> ping
> ping
> ping

Here is what I need to be able to tell it to do from a ping. A flag that allowed you to set the ping string sent would resolve the issue.

$ wsta -e wss://pubsub-edge.twitch.tv '{"type": "PING"}'
Connected to wss://pubsub-edge.twitch.tv
> {"type": "PING"}
{ "type": "PONG" }

If the ping command allowed me to send '{"type": "PING"}' as the ping data this would be perfect.

eliihen commented 7 years ago

Seems like a reasonable request. I'll see what I can do.

In the mean time, since wsta reads from stdin, you can use a script like this:

#!/bin/bash

while [ true ]; do
  echo '{"type": "PING"}'
  sleep 1
done | wsta wss://pubsub-edge.twitch.tv
eliihen commented 7 years ago

Done. It's rolling out now

ZoomyCat commented 7 years ago

Good job. I posted, went to sleep. Woke up and you had fixed it!