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) { ...@@ -213,8 +213,8 @@ var Peer = function (_WildEmitter) {
key: '_observeDataChannel', key: '_observeDataChannel',
value: function _observeDataChannel(channel, peer) { value: function _observeDataChannel(channel, peer) {
var self = this; var self = this;
channel.onclose = this.emit.bind(this, 'channelClose', channel); channel.onclose = this.emit.bind(this, 'channelClose', channel, peer);
channel.onerror = this.emit.bind(this, 'channelError', channel); channel.onerror = this.emit.bind(this, 'channelError', channel, peer);
channel.onmessage = function (event) { channel.onmessage = function (event) {
self.emit('channelMessage', self, channel.label, JSON.parse(event.data), channel, event); self.emit('channelMessage', self, channel.label, JSON.parse(event.data), channel, event);
}; };
......
...@@ -164,8 +164,8 @@ class Peer extends WildEmitter { ...@@ -164,8 +164,8 @@ class Peer extends WildEmitter {
// Internal method registering handlers for a data channel and emitting events on the peer // Internal method registering handlers for a data channel and emitting events on the peer
_observeDataChannel(channel, peer) { _observeDataChannel(channel, peer) {
const self = this; const self = this;
channel.onclose = this.emit.bind(this, 'channelClose', channel); channel.onclose = this.emit.bind(this, 'channelClose', channel, peer);
channel.onerror = this.emit.bind(this, 'channelError', channel); channel.onerror = this.emit.bind(this, 'channelError', channel, peer);
channel.onmessage = (event) => { channel.onmessage = (event) => {
self.emit('channelMessage', self, channel.label, JSON.parse(event.data), channel, event); self.emit('channelMessage', self, channel.label, JSON.parse(event.data), channel, event);
}; };
......
Markdown is supported
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