cleaner flow without trickle as get video same time?
This commit is contained in:
@@ -42,8 +42,8 @@
|
|||||||
[
|
[
|
||||||
"@electron-forge/plugin-webpack",
|
"@electron-forge/plugin-webpack",
|
||||||
{
|
{
|
||||||
"port": "4000",
|
"port": "4002",
|
||||||
"loggerPort": "9000",
|
"loggerPort": "9002",
|
||||||
"mainConfig": "./webpack.main.config.js",
|
"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:;",
|
"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": {
|
"renderer": {
|
||||||
|
|||||||
@@ -367,21 +367,22 @@ const iceServers = [
|
|||||||
// credential: 'JZEOEt2V3Qb0y27GRntt2u2PAYA=',
|
// credential: 'JZEOEt2V3Qb0y27GRntt2u2PAYA=',
|
||||||
// username: '28224511:1379330808',
|
// username: '28224511:1379330808',
|
||||||
// },
|
// },
|
||||||
// {
|
{
|
||||||
// url: 'turn:turn.bistri.com:80',
|
url: 'turn:turn.bistri.com:80',
|
||||||
// credential: 'homeo',
|
credential: 'homeo',
|
||||||
// username: 'homeo',
|
username: 'homeo',
|
||||||
// },
|
},
|
||||||
|
|
||||||
// {
|
// {
|
||||||
// url: 'turn:turn.anyfirewall.com:443?transport=tcp',
|
// url: 'turn:turn.anyfirewall.com:443?transport=tcp',
|
||||||
// credential: 'webrtc',
|
// credential: 'webrtc',
|
||||||
// username: 'webrtc',
|
// username: 'webrtc',
|
||||||
// },
|
// },
|
||||||
{
|
// {
|
||||||
url: 'turn:openrelay.metered.ca:80',
|
// url: 'turn:openrelay.metered.ca:80',
|
||||||
credential: 'openrelayproject',
|
// credential: 'openrelayproject',
|
||||||
username: 'openrelayproject',
|
// username: 'openrelayproject',
|
||||||
},
|
// },
|
||||||
];
|
];
|
||||||
|
|
||||||
function useDevices() {
|
function useDevices() {
|
||||||
@@ -471,7 +472,7 @@ function Room({
|
|||||||
const localPeerConnection = new Peer({
|
const localPeerConnection = new Peer({
|
||||||
initiator: true,
|
initiator: true,
|
||||||
stream: localMediaStream,
|
stream: localMediaStream,
|
||||||
trickle: true, // prevents the multiple tries on different ice servers and signal from getting called a bunch of times,
|
trickle: false, // prevents the multiple tries on different ice servers and signal from getting called a bunch of times,
|
||||||
config: {
|
config: {
|
||||||
iceServers,
|
iceServers,
|
||||||
},
|
},
|
||||||
@@ -508,6 +509,7 @@ function Room({
|
|||||||
setConversationMap((draft) => {
|
setConversationMap((draft) => {
|
||||||
if (draft[conversation._id.toString()].room[otherUserId]) {
|
if (draft[conversation._id.toString()].room[otherUserId]) {
|
||||||
draft[conversation._id.toString()].room[otherUserId].stream = remoteStream;
|
draft[conversation._id.toString()].room[otherUserId].stream = remoteStream;
|
||||||
|
|
||||||
remoteStream.getTracks().forEach((track) => {
|
remoteStream.getTracks().forEach((track) => {
|
||||||
// TODO: add particular track to right place
|
// TODO: add particular track to right place
|
||||||
});
|
});
|
||||||
@@ -569,7 +571,7 @@ function Room({
|
|||||||
const peerForMeAndNewbie = new Peer({
|
const peerForMeAndNewbie = new Peer({
|
||||||
initiator: false,
|
initiator: false,
|
||||||
stream: userLocalStream,
|
stream: userLocalStream,
|
||||||
trickle: true, // prevents the multiple tries on different ice servers and signal from getting called a bunch of times
|
trickle: false, // prevents the multiple tries on different ice servers and signal from getting called a bunch of times
|
||||||
config: {
|
config: {
|
||||||
iceServers,
|
iceServers,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { Socket, io } from 'socket.io-client';
|
|||||||
|
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
import useAuth from './AuthProvider';
|
import useAuth from './AuthProvider';
|
||||||
|
import { useUnmount } from 'react-use';
|
||||||
|
|
||||||
interface ISocketProvider {
|
interface ISocketProvider {
|
||||||
$ws: Socket;
|
$ws: Socket;
|
||||||
@@ -42,7 +43,7 @@ export function SocketProvider({ children }: { children: React.ReactNode }) {
|
|||||||
[set$ws],
|
[set$ws],
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
const connect = useCallback(() => {
|
||||||
if (!jwtToken) {
|
if (!jwtToken) {
|
||||||
set$ws(undefined);
|
set$ws(undefined);
|
||||||
toast.error('no jwt token!!!');
|
toast.error('no jwt token!!!');
|
||||||
@@ -60,17 +61,20 @@ export function SocketProvider({ children }: { children: React.ReactNode }) {
|
|||||||
|
|
||||||
initiateSocketStabilityListeners(socketConnection);
|
initiateSocketStabilityListeners(socketConnection);
|
||||||
set$ws(socketConnection);
|
set$ws(socketConnection);
|
||||||
|
}, [initiateSocketStabilityListeners, jwtToken, set$ws]);
|
||||||
|
|
||||||
return () => {
|
useEffect(() => {
|
||||||
socketConnection.disconnect();
|
connect();
|
||||||
socketConnection.removeAllListeners();
|
}, [connect]);
|
||||||
};
|
|
||||||
}, [set$ws, jwtToken, initiateSocketStabilityListeners]);
|
useUnmount(() => {
|
||||||
|
$ws?.disconnect();
|
||||||
|
$ws?.removeAllListeners();
|
||||||
|
});
|
||||||
|
|
||||||
const handleReconnect = useCallback(() => {
|
const handleReconnect = useCallback(() => {
|
||||||
initiateSocketStabilityListeners($ws);
|
connect();
|
||||||
$ws.connect();
|
}, [connect]);
|
||||||
}, [$ws, initiateSocketStabilityListeners]);
|
|
||||||
|
|
||||||
if (!$ws) {
|
if (!$ws) {
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user