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
Tolerate already extracted data coming from on message handler from underlying websocket #15
Comments
Hi Witalij!
The result is:
Technically, the spec you cited addresses the |
Agree. |
After I create
I overwrite the
where the only change is the check for the type of value returned by the |
I've got your point. wsp.ws.on('message', data => ...) Doesn't it solve in your case? |
@gpolakow const WebSocketAsPromised = require('websocket-as-promised');
const WebSocket = require('ws');
const wsp = new WebSocketAsPromised('ws://example.com', {
createWebSocket: url => new WebSocket(url),
extractMessageData: event => event, // <- this is important!
}); |
That's cool, thx! |
Hi there,
I have to use
ws
package because it supports setting custom headers when opening a websocket, but it turns out that it doesn't cooperate well with thewebsocket-as-promised
.ws
implements all the needed methods but in theon('message', ...
handler it doesn't pass the full event, but it passes the already extracteddata
property. Would you mind adding a little check of the incoming parameter? It's just a matter of changingto
in the
index.js
. It stays compatible with the already supported websocket implementations and, at the same time, tolerates the use ofws
. I will be happy to send PR for this if you're willing to accept such a hack.The text was updated successfully, but these errors were encountered: