Защита от принятия звонка принятого на другом устройстве

This commit is contained in:
RoyceDa
2026-04-01 14:21:11 +02:00
parent 8fbfb4fa5c
commit 0a0c810105

View File

@@ -293,8 +293,19 @@ export function CallProvider(props : CallProviderProps) {
setCallState(CallState.WEB_RTC_EXCHANGE); setCallState(CallState.WEB_RTC_EXCHANGE);
} }
if(signalType == SignalType.CREATE_ROOM) { if(signalType == SignalType.CREATE_ROOM) {
if(!sessionKeys){
/**
* Сервер может отправить CREATE_ROOM сигнал, даже если мы приняли звонок на другом устройстве, по этому проверяем,
* на этом ли устройстве звонок принят посредством проверки наличия сгенерированных ключей шифрования
*/
stopLoopSound();
stopSound();
end();
return;
}
/** /**
* Создана комната для обмена WebRTC потоками * Создана комната для обмена WebRTC потоками, но такое событие сервер может отправить даже если звонок
* был принят с другого устройства, по этому проверяем, наш ли звонок
*/ */
roomIdRef.current = packet.getRoomId(); roomIdRef.current = packet.getRoomId();
info("WebRTC room created with id: " + packet.getRoomId()); info("WebRTC room created with id: " + packet.getRoomId());
@@ -443,8 +454,7 @@ export function CallProvider(props : CallProviderProps) {
/** /**
* Только если звонок был активен воспроизводим звуки * Только если звонок был активен воспроизводим звуки
*/ */
stopLoopSound(); playSound("end_call.mp3");
stopSound();
} }
if (remoteAudioRef.current) { if (remoteAudioRef.current) {
remoteAudioRef.current.pause(); remoteAudioRef.current.pause();
@@ -454,7 +464,6 @@ export function CallProvider(props : CallProviderProps) {
setDuration(0); setDuration(0);
durationIntervalRef.current && clearInterval(durationIntervalRef.current); durationIntervalRef.current && clearInterval(durationIntervalRef.current);
setWindowPriority(false); setWindowPriority(false);
playSound("end_call.mp3");
peerConnectionRef.current?.close(); peerConnectionRef.current?.close();
peerConnectionRef.current = null; peerConnectionRef.current = null;
roomIdRef.current = ""; roomIdRef.current = "";