Skip to content

Commit

Permalink
lib: fix W3C WebSocket event forwarding
Browse files Browse the repository at this point in the history
PR-URL: #266
Reviewed-By: Timur Shemsedinov <timur.shemsedinov@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Reviewed-By: Mykola Bilochub <nbelochub@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
  • Loading branch information
nechaido committed Jul 25, 2017
1 parent 87947ee commit 4d76172
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/ws-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
const EventEmitter = require('events').EventEmitter;

const serde = require('./serde');
const common = require('./common');
const constants = require('./internal-constants');
const transportCommon = require('./transport-common');

Expand All @@ -22,7 +21,12 @@ class Transport extends EventEmitter {
this._onMessage(message);
};

common.forwardMultipleEvents(this.socket, this, ['close', 'error']);

['close', 'error'].forEach((event) => {
this.socket.addEventListener(event, (...args) => {
this.emit(event, ...args);
});
});
}

// returns underlying socket.
Expand Down

0 comments on commit 4d76172

Please sign in to comment.