trying more stuff with error

This commit is contained in:
talksik
2022-07-06 18:53:12 -05:00
parent 5062b39c82
commit cc01719669
2 changed files with 138 additions and 128 deletions
+2 -2
View File
@@ -42,8 +42,8 @@
[
"@electron-forge/plugin-webpack",
{
"port": "4000",
"loggerPort": "9000",
"port": "4005",
"loggerPort": "9005",
"mainConfig": "./webpack.main.config.js",
"devContentSecurityPolicy": "default-src * self blob: data: gap:; style-src * self 'unsafe-inline' blob: data: gap:; script-src * 'self' 'unsafe-eval' 'unsafe-inline' blob: data: gap:; object-src * 'self' blob: data: gap:; img-src * self 'unsafe-inline' blob: data: gap:; connect-src self * 'unsafe-inline' blob: data: gap:; frame-src * self blob: data: gap:;",
"renderer": {
@@ -627,16 +627,17 @@ function Room({
// handle incoming calls and accept calls and create objects for them
useEffectOnce(() => {
(async () => {
// TODO : bring this stream object higher and add this later to the room
// set up local stream for this room - temporary until we figure out global stream handling and passing down
// const localMediaStream = await navigator.mediaDevices.getUserMedia({
// video: videoConstraints,
// audio: true,
// });
const localMediaStream = await navigator.mediaDevices.getUserMedia({
video: VIDEO_CONSTRAINTS,
audio: AUDIO_CONSTRAINTS,
});
// console.log(localMediaStream);
console.log(localMediaStream);
// setUserLocalStream(localMediaStream);
setUserLocalStream(localMediaStream);
// ?will there be race condition where this room component is rendered but we don't have the latest
// ?list of tunedin folks and so we may just end up calling select few?
@@ -656,7 +657,7 @@ function Room({
// make sure this peer gets destroyed when it's time to remove this listener
const localPeerConnection = new Peer({
initiator: true,
// stream: localMediaStream,
stream: localMediaStream,
trickle: false, // prevents the multiple tries on different ice servers and signal from getting called a bunch of times,
config: {
iceServers,
@@ -728,7 +729,9 @@ function Room({
setConversationMap((draft) => {
if (draft[conversation._id.toString()].room[otherUserId]) {
draft[conversation._id.toString()].room[otherUserId].peer?.destroy();
draft[conversation._id.toString()].room[otherUserId].peer?.destroy(
new Error('destroying!'),
);
delete draft[conversation._id.toString()].room[otherUserId];
}
});
@@ -742,13 +745,16 @@ function Room({
setConversationMap((draft) => {
if (draft[conversation._id.toString()].room[otherUserId]) {
draft[conversation._id.toString()].room[otherUserId].peer?.destroy();
draft[conversation._id.toString()].room[otherUserId].peer?.destroy(
new Error('destroying!'),
);
delete draft[conversation._id.toString()].room[otherUserId];
}
});
});
});
}
})();
});
// ======= LISTEN FOR INCOMING CALLS AND RETURN SIGNALS AND ACCEPT THEM
@@ -768,7 +774,7 @@ function Room({
const peerForMeAndNewbie = new Peer({
initiator: false,
// stream: userLocalStream,
stream: userLocalStream,
trickle: false, // prevents the multiple tries on different ice servers and signal from getting called a bunch of times
config: {
iceServers,
@@ -833,7 +839,9 @@ function Room({
setConversationMap((draft) => {
if (draft[conversation._id.toString()].room[res.userWhoCalled]) {
draft[conversation._id.toString()].room[res.userWhoCalled].peer?.destroy();
draft[conversation._id.toString()].room[res.userWhoCalled].peer?.destroy(
new Error('destroying!'),
);
delete draft[conversation._id.toString()].room[res.userWhoCalled];
}
});
@@ -849,7 +857,9 @@ function Room({
setConversationMap((draft) => {
if (draft[conversation._id.toString()].room[res.userWhoCalled]) {
draft[conversation._id.toString()].room[res.userWhoCalled].peer?.destroy();
draft[conversation._id.toString()].room[res.userWhoCalled].peer?.destroy(
new Error('destroying!'),
);
delete draft[conversation._id.toString()].room[res.userWhoCalled];
}
});
@@ -889,7 +899,7 @@ function Room({
if (!conversation.tunedInUsers.includes(roomUserId)) {
console.log('someone left the room!!!');
roomContents.peer.destroy();
roomContents.peer.destroy(new Error('destroying!'));
delete draft[conversation._id.toString()].room[roomUserId];
}
@@ -904,7 +914,7 @@ function Room({
setConversationMap((draft) => {
if (draft[conversation._id.toString()].room) {
Object.values(draft[conversation._id.toString()].room).forEach((roomPeerContents) => {
roomPeerContents.peer.destroy();
roomPeerContents.peer.destroy(new Error('destroying!'));
console.log('destroyed peer connection as I am leaving room');
});