diff --git a/src/RTCDataChannel.js b/src/RTCDataChannel.js index 825da40..5138ce9 100644 --- a/src/RTCDataChannel.js +++ b/src/RTCDataChannel.js @@ -151,6 +151,7 @@ module.exports = function (daemon, wrtc) { break } + this.emit(message.type, event) if (handler) handler(event) } diff --git a/src/RTCPeerConnection.js b/src/RTCPeerConnection.js index f1ba7fe..72c8668 100644 --- a/src/RTCPeerConnection.js +++ b/src/RTCPeerConnection.js @@ -1,5 +1,6 @@ 'use strict' +var EventEmitter = require('events').EventEmitter var hat = require('hat') var debug = require('debug')('RTCPC') @@ -11,8 +12,9 @@ module.exports = function (daemon, wrtc) { if (err) wrtc.emit('error', err) }) - return class RTCPeerConnection { + return class RTCPeerConnection extends EventEmitter { constructor (opts) { + super() if (daemon.closing) { throw new Error('Cannot create RTCPeerConnection, the electron-webrtc daemon has been closed') } @@ -170,6 +172,7 @@ module.exports = function (daemon, wrtc) { break } + this.emit(message.type, event) if (handler) handler(event) }