Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //...
- //Payload is received from the websockets server
- const {data} = payload;
- if (data.sdp) {
- await peerConnection.setRemoteDescription(data.sdp);
- if (data.sdp.type === 'offer') {
- const answer = await peerConnection.createAnswer();
- await peerConnection.setLocalDescription(answer);
- const answerPayload = {
- sdp: answer,
- chat: chatId,
- };
- chat.signaling(answerPayload, chatId);
- }
- } else if (data.ice) {
- await peerConnection.addIceCandidate(data.ice);
- }
- //...
- //When the user presses on the call button
- if (isCaller) {
- const offer = await peerConnection.createOffer();
- await peerConnection.setLocalDescription(offer);
- const payload = {
- sdp: offer,
- chat: chatId,
- };
- //Send the payload to the server
- }
Advertisement
Add Comment
Please, Sign In to add comment