From 35362f54679cd917c77702072d1002a29acfc65f Mon Sep 17 00:00:00 2001 From: Adam Butler Date: Mon, 9 May 2016 22:55:32 +0100 Subject: [PATCH 1/2] Fix call to sender (instead of peer) on event --- MultipeerConnection.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MultipeerConnection.js b/MultipeerConnection.js index 0fa064b..dd94fe7 100644 --- a/MultipeerConnection.js +++ b/MultipeerConnection.js @@ -59,7 +59,7 @@ export default class MultipeerConnection extends EventEmitter { var invited = DeviceEventEmitter.addListener( 'RCTMultipeerConnectivityInviteReceived', ((event) => { - event.sender = this._peers[event.sender.id]; + event.sender = this._peers[event.peer.id]; this.emit('invite', event); }).bind(this)); From 1d2a99bbbe4504b1ce95283d73726b4c9ec933b8 Mon Sep 17 00:00:00 2001 From: Adam Butler Date: Mon, 9 May 2016 22:56:45 +0100 Subject: [PATCH 2/2] Prevent an exception when RTCMultipeerConnectivityPeerDisconnected event is raised but the peer does not exist in the peers array. --- MultipeerConnection.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/MultipeerConnection.js b/MultipeerConnection.js index dd94fe7..5b84f88 100644 --- a/MultipeerConnection.js +++ b/MultipeerConnection.js @@ -45,9 +45,11 @@ export default class MultipeerConnection extends EventEmitter { var peerDisconnected = DeviceEventEmitter.addListener( 'RCTMultipeerConnectivityPeerDisconnected', ((event) => { - this._peers[event.peer.id].emit('disconnected'); - delete this._connectedPeers[event.peer.id]; - this.emit('peerDisconnected', event); + if(this._peers[event.peer.id]) { + this._peers[event.peer.id].emit('disconnected'); + delete this._connectedPeers[event.peer.id]; + this.emit('peerDisconnected', event); + }; }).bind(this)); var streamOpened = DeviceEventEmitter.addListener(