|
@@ -42,7 +42,7 @@ const useStyles = makeStyles({
|
|
backgroundColor: 'rgba(104, 105, 104, 0.6)',
|
|
backgroundColor: 'rgba(104, 105, 104, 0.6)',
|
|
},
|
|
},
|
|
shareScreenActive: {
|
|
shareScreenActive: {
|
|
- width: '90%',
|
|
|
|
|
|
+ width: '30%',
|
|
borderRadius: 7,
|
|
borderRadius: 7,
|
|
margin: 'auto',
|
|
margin: 'auto',
|
|
border:'solid 2px #0084ff',
|
|
border:'solid 2px #0084ff',
|
|
@@ -59,7 +59,7 @@ const useStyles = makeStyles({
|
|
alignItems: 'center',
|
|
alignItems: 'center',
|
|
justifyItems:"center",
|
|
justifyItems:"center",
|
|
width: '34vw',
|
|
width: '34vw',
|
|
- height:'50vh',
|
|
|
|
|
|
+ height:'90vh',
|
|
borderRadius: 7,
|
|
borderRadius: 7,
|
|
},
|
|
},
|
|
rightIcons: {
|
|
rightIcons: {
|
|
@@ -157,16 +157,17 @@ const CallBar = ({callStatus,setCallStatus,socket,myVideoRef}:ICallBar) => {
|
|
const classes = useStyles()
|
|
const classes = useStyles()
|
|
const { _id } = useSelector(getAuthorizationState)
|
|
const { _id } = useSelector(getAuthorizationState)
|
|
const chat = useSelector(getChat)
|
|
const chat = useSelector(getChat)
|
|
|
|
+ const myAudioRef = useRef<any>(null);
|
|
|
|
+ const userAudioRef = useRef<any>(null);
|
|
const userVideoRef = useRef<any>(null);
|
|
const userVideoRef = useRef<any>(null);
|
|
|
|
+ const connectionRef = useRef<any>(null);
|
|
const [mySocket, setMySocket] = useState<string>('')
|
|
const [mySocket, setMySocket] = useState<string>('')
|
|
|
|
+ const [companionSocket, setCompanionSocket] = useState<string>('')
|
|
const [name, setName] = useState<string>('')
|
|
const [name, setName] = useState<string>('')
|
|
const [lastName, setLastName] = useState<string>('')
|
|
const [lastName, setLastName] = useState<string>('')
|
|
const [avatarUrl, setAvatarUrl] = useState<string>('')
|
|
const [avatarUrl, setAvatarUrl] = useState<string>('')
|
|
const [color, setColor] = useState<string>('')
|
|
const [color, setColor] = useState<string>('')
|
|
const [number,setNumber] = useState<string>('')
|
|
const [number,setNumber] = useState<string>('')
|
|
- const myAudioRef = useRef<any>(null);
|
|
|
|
- const userAudioRef = useRef<any>(null);
|
|
|
|
- const connectionRef = useRef<any>(null);
|
|
|
|
const handleLeaveCall = () => {
|
|
const handleLeaveCall = () => {
|
|
connectionRef.current.destroy();
|
|
connectionRef.current.destroy();
|
|
setCallStatus('')
|
|
setCallStatus('')
|
|
@@ -193,12 +194,14 @@ const CallBar = ({callStatus,setCallStatus,socket,myVideoRef}:ICallBar) => {
|
|
})
|
|
})
|
|
setCallStatus('ringing')
|
|
setCallStatus('ringing')
|
|
});
|
|
});
|
|
- peer.on("stream", (streams:any) => {});
|
|
|
|
- socket.on("acceptedCall", ({ signal }: any) => {
|
|
|
|
- peer.signal(signal)
|
|
|
|
- setCallStatus('accepted')
|
|
|
|
- console.log(signal,'signal accepted from companion')
|
|
|
|
- });
|
|
|
|
|
|
+ // peer.on("stream", (stream: any) => {
|
|
|
|
+ // console.log(stream,'user stream')
|
|
|
|
+ // });
|
|
|
|
+ // socket.on("acceptedCall", ({ signal }: any) => {
|
|
|
|
+ // // peer.signal(signal)
|
|
|
|
+ // setCallStatus('accepted')
|
|
|
|
+ // console.log(signal,'signal accepted from companion')
|
|
|
|
+ // });
|
|
connectionRef.current = peer;
|
|
connectionRef.current = peer;
|
|
},[chat.socketId,chat.companionId,_id,socket,setCallStatus,mySocket])
|
|
},[chat.socketId,chat.companionId,_id,socket,setCallStatus,mySocket])
|
|
|
|
|
|
@@ -213,13 +216,15 @@ const CallBar = ({callStatus,setCallStatus,socket,myVideoRef}:ICallBar) => {
|
|
stream,
|
|
stream,
|
|
});
|
|
});
|
|
peer.on("signal", (data: any) => {
|
|
peer.on("signal", (data: any) => {
|
|
- socket.emit("answerCall", { signal: data, to: chat.socketId });
|
|
|
|
|
|
+ socket.emit("answerCall", { signal: data, to: companionSocket });
|
|
console.log(data,'sent the signal on answer')
|
|
console.log(data,'sent the signal on answer')
|
|
});
|
|
});
|
|
- peer.on("stream", (streams:any) => {});
|
|
|
|
- peer.signal();
|
|
|
|
|
|
+ // peer.on("stream", (stream: any) => {
|
|
|
|
+ // console.log(stream,'user stream')
|
|
|
|
+ // });
|
|
|
|
+ // peer.signal();
|
|
connectionRef.current = peer;
|
|
connectionRef.current = peer;
|
|
- },[socket,chat.socketId])
|
|
|
|
|
|
+ },[socket,companionSocket])
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
socket.on("me", (id: string) => {
|
|
socket.on("me", (id: string) => {
|
|
@@ -233,9 +238,13 @@ const CallBar = ({callStatus,setCallStatus,socket,myVideoRef}:ICallBar) => {
|
|
setAvatarUrl(data.avatarUrl)
|
|
setAvatarUrl(data.avatarUrl)
|
|
setColor(data.color)
|
|
setColor(data.color)
|
|
setNumber(data.number)
|
|
setNumber(data.number)
|
|
|
|
+ setCompanionSocket(data.from)
|
|
console.log(data,'incomeCall')
|
|
console.log(data,'incomeCall')
|
|
})
|
|
})
|
|
- },[socket,setCallStatus,setName,setLastName,handleAnswerCall])
|
|
|
|
|
|
+ socket.on('acceptedCall', (data: any) => {
|
|
|
|
+ console.log(data,'acceptedCall')
|
|
|
|
+ })
|
|
|
|
+ },[socket,setCallStatus,setName,setLastName,setCompanionSocket])
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
if(callStatus === 'requesting') handleStartCall()
|
|
if(callStatus === 'requesting') handleStartCall()
|
|
@@ -278,7 +287,7 @@ const CallBar = ({callStatus,setCallStatus,socket,myVideoRef}:ICallBar) => {
|
|
<ListItemText primary={number} primaryTypographyProps={{ color: '#ffffff', fontSize: 15, fontWeight: 500,textAlign:"center" }}/>
|
|
<ListItemText primary={number} primaryTypographyProps={{ color: '#ffffff', fontSize: 15, fontWeight: 500,textAlign:"center" }}/>
|
|
<ListItemText secondary={callStatus+'...'} secondaryTypographyProps={{ color: "#dfdfdf",textAlign: "center" }} />
|
|
<ListItemText secondary={callStatus+'...'} secondaryTypographyProps={{ color: "#dfdfdf",textAlign: "center" }} />
|
|
</div>}
|
|
</div>}
|
|
- <video className={false?classes.shareScreenActive:classes.shareScreenDisabled} ref={userVideoRef} playsInline muted autoPlay/>
|
|
|
|
|
|
+ <video className={true ? classes.shareScreenActive : classes.shareScreenDisabled} ref={userVideoRef} playsInline autoPlay />
|
|
<div className={classes.bottomWrapper}>
|
|
<div className={classes.bottomWrapper}>
|
|
{!true&&<div className={classes.bottomItem}>
|
|
{!true&&<div className={classes.bottomItem}>
|
|
<Avatar className={classes.bottomIcon}
|
|
<Avatar className={classes.bottomIcon}
|