vi / websocat

Command-line client for WebSockets, like netcat (or curl) for ws:// with advanced socat-like functions
MIT License
7.17k stars 278 forks source link

To capture specific field data #45

Closed gh-ghost closed 5 years ago

gh-ghost commented 5 years ago

When I use this tool create a websocket, it will keep connection get data continuously, If I can just request a specific field data, when I get it then disconnect the connection?

for example, I just want to get this in the field {"data":{"count":{"number":}}}

vi commented 5 years ago

Are those JSON blocks transferred using WebSocket messages?

It requires additional scripts to be implemented, with hacks. Or just a separate non-Websocat solution.

Close analogue is:

websocat ... | jq --unbuffered  '.data.count.number' | grep -m 1 -v null

, but that does not close connection on match, only somewhat later.

Workaround kludge:

websocat ... | jq --unbuffered  '.data.count.number' | { grep -v null -m 1; killall websocat; }
gh-ghost commented 5 years ago

Workaround kludge:

websocat ... | jq --unbuffered  '.data.count.number' | { grep -v null -m 1; killall websocat; }

Thank You for your guide, it's helpful.