Skip to content

Commit

Permalink
Fixed issue with WebRTC signalling
Browse files Browse the repository at this point in the history
  • Loading branch information
f-r00t committed Nov 20, 2023
1 parent 9aa913c commit a4d345c
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/Recipients.js
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ function startPeer() {
],
iceTransportPolicy: "all",
sdpSemantics: 'unified-plan',
// trickle: false
trickle: false
});

return peer;
Expand Down Expand Up @@ -1457,6 +1457,7 @@ export class CallScreenNoTranslation extends React.Component {

if (type === "new") {
sessionDescription = await this.state.activeCall.peer.createOffer();

} else if (type === "incoming") {

await this.state.activeCall.peer.setRemoteDescription(data);
Expand All @@ -1467,10 +1468,24 @@ export class CallScreenNoTranslation extends React.Component {
//Set local sdp
await this.state.activeCall.peer.setLocalDescription(sessionDescription);

await this.checkPeerIceState()
await new Promise((resolve) => {
if (this.state.activeCall.peer.iceGatheringState === 'complete') {
resolve();
} else {
this.state.activeCall.peer.addEventListener('icegatheringstatechange', () => {
if (this.state.activeCall.peer.iceGatheringState === 'complete') {
resolve();
}
});
}
});

//Set Answer/Offer
if (type === "new") sessionDescription = await this.state.activeCall.peer.createOffer();
if (type === "incoming") {
await this.state.activeCall.peer.setRemoteDescription(data);
sessionDescription = await this.state.activeCall.peer.createAnswer();
}

let message = {
type: sessionDescription.type,
Expand All @@ -1492,7 +1507,7 @@ export class CallScreenNoTranslation extends React.Component {
Globals.logger.addLogMessage('[DataChannel] Error parsing data channel message: ' + data);
return
}
Globals.logger.addLogMessage('[DataChannel] incoming: ' + message);
Globals.logger.addLogMessage('[DataChannel] incoming: ' + JSON.stringify(message));
const incomingCall = this.checkIncomingCall(message)
if (incomingCall) return

Expand Down Expand Up @@ -1568,7 +1583,11 @@ export class CallScreenNoTranslation extends React.Component {

let messageKey = this.state.paymentID;

sendMessage(parsed_data, receiver, messageKey);
const result = await sendMessage(parsed_data, receiver, messageKey);
console.log(result);
if (!result.success) {
toastPopUp('Failed to send call! Check your balance and try again.');
}

}

Expand Down

0 comments on commit a4d345c

Please sign in to comment.