react-peer-chat 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +27 -22
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import useStorage, { removeStorage } from './storage.js';
|
|
3
3
|
import { BiSolidMessageDetail, BiSolidMessageX, BsFillMicFill, BsFillMicMuteFill, GrSend } from './icons.js';
|
|
4
|
-
export default function Chat({ name, peerId, remotePeerId, peerOptions, text = true, voice = true, dialogOptions, onError = () =>
|
|
4
|
+
export default function Chat({ name, peerId, remotePeerId, peerOptions, text = true, voice = true, dialogOptions, onError = () => alert("Microphone not accessible!"), children, props = {} }) {
|
|
5
5
|
const [peer, setPeer] = useState();
|
|
6
6
|
const [notification, setNotification] = useState(false);
|
|
7
7
|
const [remotePeer, setRemotePeer] = useStorage('rpc-remote-peer', '', { save: true });
|
|
@@ -64,27 +64,32 @@ export default function Chat({ name, peerId, remotePeerId, peerOptions, text = t
|
|
|
64
64
|
}
|
|
65
65
|
if (audio) {
|
|
66
66
|
const getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
call
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
67
|
+
try {
|
|
68
|
+
getUserMedia({
|
|
69
|
+
video: false,
|
|
70
|
+
audio: {
|
|
71
|
+
autoGainControl: false,
|
|
72
|
+
noiseSuppression: true,
|
|
73
|
+
echoCancellation: true
|
|
74
|
+
}
|
|
75
|
+
}, (stream) => {
|
|
76
|
+
localStream.current = stream;
|
|
77
|
+
if (remotePeerId) {
|
|
78
|
+
call = peer.call(remotePeerId, stream);
|
|
79
|
+
call.on('stream', handleRemoteStream);
|
|
80
|
+
call.on('close', call.removeAllListeners);
|
|
81
|
+
}
|
|
82
|
+
peer.on('call', e => {
|
|
83
|
+
call = e;
|
|
84
|
+
call.answer(stream);
|
|
85
|
+
call.on('stream', handleRemoteStream);
|
|
86
|
+
call.on('close', call.removeAllListeners);
|
|
87
|
+
});
|
|
88
|
+
}, onError);
|
|
89
|
+
}
|
|
90
|
+
catch (_a) {
|
|
91
|
+
onError();
|
|
92
|
+
}
|
|
88
93
|
}
|
|
89
94
|
});
|
|
90
95
|
peer.on('connection', handleConnection);
|