Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message option (-m, --message) #17

Closed
wants to merge 2 commits into from

Conversation

eliihen
Copy link

@eliihen eliihen commented Feb 29, 2016

Why

Where I work we stream loads of market data, and the client is the boss of what it would like to stream. It can decide to stream the Oslo stock exchange in real time, for example. This we do via a subscribe string.

When working with services that use websockets, we usually don't get it right the first time. This means that we have to work on our servlet, then use wscat to check the data is correct, make changes and restart. It would be great to be able to just use arrow up to do the same subscribe, and not have to have the subscribe string in notepad on the side, using copy and paste to get the data out from the server.

It is also useful to be able to send a single wscat command to another developer, and not two commands they have to do in sequence. Minor, but a quality of life bump that is much appreciated.

This change would also make scripting easier, as you could simply pipe the command into grep, awk, etc, without having to do clever bash workarounds to send that inital message.

What

This PR adds a new argument, -m, --message. This tells wscat to send the provided message to the server as soon as it is ready.

Result

$ wscat -c wss://bors.e24.no/server/components --message 'subscribe?columns=LONG_NAME&itemSector=OSEBX.OSE'
connected (press CTRL+C to quit)
> subscribe?columns=LONG_NAME&itemSector=OSEBX.OSE
< {"id":"dc5b617c656a177415aa7417ef332af6","channel":null}
< {"id":"dc5b617c656a177415aa7417ef332af6","values":{"LONG_NAME":"Hovedindeksen"},"type":"new","key":"OSEBX_OSE"}
>

@nwwells
Copy link
Collaborator

nwwells commented Jan 24, 2017

@esphen, Do you mind resolving the conflicts and then I'll merge?

@nwwells
Copy link
Collaborator

nwwells commented Jan 24, 2017

Actually, as I think about it, it makes sense to grab the message from stdin. Does that seem reasonable to you, @esphen ?

@nwwells
Copy link
Collaborator

nwwells commented Jan 24, 2017

Looking at this, it looks like wscat2 already included this PR, which will then be represented in #30. I think we can close this and just wait for that to merge.

@nwwells nwwells closed this Jan 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants