From df37ed93fbd933c843ed35fc98c29fd7fe339fb7 Mon Sep 17 00:00:00 2001 From: Jerko Steiner Date: Sun, 18 Jun 2017 08:56:11 -0400 Subject: [PATCH] Allow peers w/o streams to receive streams, closes #26 Related to: https://github.com/feross/simple-peer/issues/95 --- src/client/actions/CallActions.js | 2 +- src/client/actions/PeerActions.js | 10 ++++++++-- src/client/actions/__tests__/CallActions-test.js | 6 +++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/client/actions/CallActions.js b/src/client/actions/CallActions.js index 08faa9d..f6e6757 100644 --- a/src/client/actions/CallActions.js +++ b/src/client/actions/CallActions.js @@ -45,6 +45,6 @@ export const getCameraStream = () => dispatch => { }) .catch(err => { dispatch(NotifyActions.alert('Could not get access to microphone & camera')) - throw err + return null }) } diff --git a/src/client/actions/PeerActions.js b/src/client/actions/PeerActions.js index 2300877..7e44a39 100644 --- a/src/client/actions/PeerActions.js +++ b/src/client/actions/PeerActions.js @@ -83,8 +83,14 @@ export function createPeer ({ socket, user, initiator, stream }) { const peer = new Peer({ initiator: socket.id === initiator, - stream, - config: { iceServers } + config: { iceServers }, + // Allow the peer to receive video, even if it's not sending stream: + // https://github.com/feross/simple-peer/issues/95 + offerConstraints: { + offerToReceiveAudio: true, + offerToReceiveVideo: true + }, + stream }) const handler = new PeerHandler({ diff --git a/src/client/actions/__tests__/CallActions-test.js b/src/client/actions/__tests__/CallActions-test.js index bc6abe2..7b4fd34 100644 --- a/src/client/actions/__tests__/CallActions-test.js +++ b/src/client/actions/__tests__/CallActions-test.js @@ -80,11 +80,11 @@ describe('reducers/alerts', () => { const promise = store.dispatch(CallActions.init()) socket.emit('connect') promise - .then(done.fail) - .catch(err => { - expect(err.message).toEqual('test') + .then(result => { + expect(result.value).toBe(null) done() }) + .catch(done.fail) }) })