Commit afa8666f authored by Moritz Langenstein's avatar Moritz Langenstein
Browse files

(ml5717) Pass along peer on channel close and error events

parent 14adace8
......@@ -213,8 +213,8 @@ var Peer = function (_WildEmitter) {
key: '_observeDataChannel',
value: function _observeDataChannel(channel, peer) {
var self = this;
channel.onclose = this.emit.bind(this, 'channelClose', channel);
channel.onerror = this.emit.bind(this, 'channelError', channel);
channel.onclose = this.emit.bind(this, 'channelClose', channel, peer);
channel.onerror = this.emit.bind(this, 'channelError', channel, peer);
channel.onmessage = function (event) {
self.emit('channelMessage', self, channel.label, JSON.parse(event.data), channel, event);
};
......
......@@ -164,8 +164,8 @@ class Peer extends WildEmitter {
// Internal method registering handlers for a data channel and emitting events on the peer
_observeDataChannel(channel, peer) {
const self = this;
channel.onclose = this.emit.bind(this, 'channelClose', channel);
channel.onerror = this.emit.bind(this, 'channelError', channel);
channel.onclose = this.emit.bind(this, 'channelClose', channel, peer);
channel.onerror = this.emit.bind(this, 'channelError', channel, peer);
channel.onmessage = (event) => {
self.emit('channelMessage', self, channel.label, JSON.parse(event.data), channel, event);
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment