koa-ws icon indicating copy to clipboard operation
koa-ws copied to clipboard

Client onMessage bug?

Open zimond opened this issue 8 years ago • 1 comments

in client.js, Client.prototype.onMessage, the argument is e, so this method would be:

Client.prototype.onMessage = function (e) {
    protocol.apply(this, [debug, this.socket, e.data]);
};

Maybe I missed something?

zimond avatar Dec 09 '15 01:12 zimond

If using the client in the browser then, yes, the argument is the event, e. But if you use the client directly inside a node module, the argument is just the data. The onMessage method should be updated to handle either case:

Client.prototype.onMessage = function (e) {
    protocol.apply(this, [debug, this.socket, e.data || e]);
};

adamgruber avatar Aug 20 '17 14:08 adamgruber