pladaria / reconnecting-websocket

Reconnecting WebSocket. For Web, React Native, cli (Node.js)
MIT License
1.23k stars 200 forks source link

How to use "ws.once" with this library? #174

Closed regisfaria closed 2 years ago

regisfaria commented 2 years ago

Hello!

I adopted this package when I was needing to have my WS connections restarted if they disconnect. It worked perfectly in my case, since I was using this to follow up crypto-currencies value changes. Thank you for that!

Now I wish to also have a channel open, using this package, but I lack one functionality that my code needs, which is the method: ".once("message",() => {})". I use this to send crypto orders and get their respective message right after.

Anyone have ideas on how to achieve that?

I need to follow one pipeline of: send data to ws server -> get the message and send new data -> get message and send -> ... and so on until I achieve the end(I usually do this around 4 times), which is a variable full of specific data for my app.

Searching through the "reconnecting-websocket" lib I found no "once" method.

I really appreciate if anyone can help me.