diff --git a/app/providers/CallProvider/CallProvider.tsx b/app/providers/CallProvider/CallProvider.tsx index 572a122..cd05e4a 100644 --- a/app/providers/CallProvider/CallProvider.tsx +++ b/app/providers/CallProvider/CallProvider.tsx @@ -16,6 +16,7 @@ import { attachReceiverE2EE, attachSenderE2EE } from "./audioE2EE"; import { useDeattachedSender } from "../DialogProvider/useDeattachedSender"; import { AttachmentType } from "../ProtocolProvider/protocol/packets/packet.message"; import { generateRandomKey } from "@/app/utils/utils"; +import { useCoreDevice } from "../DeviceProvider/useCoreDevice"; export interface CallContextValue { call: (callable: string) => void; @@ -85,6 +86,7 @@ export function CallProvider(props : CallProviderProps) { const soundRef = useRef(true); const {sendMessage} = useDeattachedSender(); const hasRemoteTrackRef = useRef(false); + const { deviceId } = useCoreDevice(); const {playSound, stopSound, stopLoopSound} = useSound(); const {setWindowPriority} = useWindow(); @@ -170,7 +172,6 @@ export function CallProvider(props : CallProviderProps) { * Другая сторона отправила нам ICE кандидата для установления WebRTC соединения */ const candidate = JSON.parse(packet.getSdpOrCandidate()); - console.info(candidate); if(peerConnectionRef.current?.remoteDescription == null){ /** * Удаленное описание еще не установлено, буферизуем кандидата, чтобы добавить его после установки удаленного описания @@ -195,6 +196,8 @@ export function CallProvider(props : CallProviderProps) { let answerSignal = new PacketWebRTC(); answerSignal.setSignalType(WebRTCSignalType.ANSWER); answerSignal.setSdpOrCandidate(JSON.stringify(answer)); + answerSignal.setPublicKey(publicKey); + answerSignal.setDeviceId(deviceId); send(answerSignal); info("Received WebRTC offer, set remote description and sent answer"); return; @@ -338,6 +341,8 @@ export function CallProvider(props : CallProviderProps) { let candidateSignal = new PacketWebRTC(); candidateSignal.setSignalType(WebRTCSignalType.ICE_CANDIDATE); candidateSignal.setSdpOrCandidate(JSON.stringify(event.candidate)); + offerSignal.setPublicKey(publicKey); + offerSignal.setDeviceId(deviceId); send(candidateSignal); } } @@ -399,6 +404,8 @@ export function CallProvider(props : CallProviderProps) { let offerSignal = new PacketWebRTC(); offerSignal.setSignalType(WebRTCSignalType.OFFER); offerSignal.setSdpOrCandidate(JSON.stringify(offer)); + offerSignal.setPublicKey(publicKey); + offerSignal.setDeviceId(deviceId); send(offerSignal); return; } diff --git a/app/providers/ProtocolProvider/protocol/packets/packet.webrtc.ts b/app/providers/ProtocolProvider/protocol/packets/packet.webrtc.ts index 9a5ca74..8641b4b 100644 --- a/app/providers/ProtocolProvider/protocol/packets/packet.webrtc.ts +++ b/app/providers/ProtocolProvider/protocol/packets/packet.webrtc.ts @@ -15,6 +15,8 @@ export class PacketWebRTC extends Packet { private signalType: WebRTCSignalType = WebRTCSignalType.OFFER; private sdpOrCandidate: string = ""; + private publicKey: string = ""; + private deviceId: string = ""; public getPacketId(): number { return 27; @@ -23,6 +25,8 @@ export class PacketWebRTC extends Packet { public _receive(stream: Stream): void { this.signalType = stream.readInt8(); this.sdpOrCandidate = stream.readString(); + this.publicKey = stream.readString(); + this.deviceId = stream.readString(); } public _send(): Promise | Stream { @@ -30,6 +34,8 @@ export class PacketWebRTC extends Packet { stream.writeInt16(this.getPacketId()); stream.writeInt8(this.signalType); stream.writeString(this.sdpOrCandidate); + stream.writeString(this.publicKey); + stream.writeString(this.deviceId); return stream; } @@ -49,4 +55,20 @@ export class PacketWebRTC extends Packet { return this.sdpOrCandidate; } + public setPublicKey(key: string) { + this.publicKey = key; + } + + public getPublicKey(): string { + return this.publicKey; + } + + public setDeviceId(id: string) { + this.deviceId = id; + } + + public getDeviceId(): string { + return this.deviceId; + } + } \ No newline at end of file