-
Notifications
You must be signed in to change notification settings - Fork 48
Fix ice candidate proto to webrtc interface conversion #386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -242,8 +242,9 @@ export class SignalingExchange { | |
try { | ||
await this.pc.addIceCandidate(cand); | ||
} catch (error) { | ||
console.log('error adding ice candidate', error); // eslint-disable-line no-console | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will report an error if this ever happens again and bubble up to the reason of dial failure instead of undefined. |
||
await this.sendError(JSON.stringify(error)); | ||
return false; | ||
throw error; | ||
} | ||
|
||
return true; | ||
|
@@ -263,7 +264,7 @@ export class SignalingExchange { | |
return; | ||
} | ||
|
||
if (!this.callUuid) { | ||
if (this.callUuid === undefined || this.callUuid === '') { | ||
throw new Error(callUUIDUnset); | ||
} | ||
|
||
|
@@ -307,7 +308,7 @@ export class SignalingExchange { | |
if (this.sentDoneOrErrorOnce) { | ||
return; | ||
} | ||
if (!this.callUuid) { | ||
if (this.callUuid === undefined || this.callUuid === '') { | ||
throw new Error(callUUIDUnset); | ||
} | ||
this.sentDoneOrErrorOnce = true; | ||
|
@@ -337,7 +338,7 @@ export class SignalingExchange { | |
if (this.sentDoneOrErrorOnce) { | ||
return; | ||
} | ||
if (!this.callUuid) { | ||
if (this.callUuid === undefined || this.callUuid === '') { | ||
throw new Error(callUUIDUnset); | ||
} | ||
this.sentDoneOrErrorOnce = true; | ||
|
@@ -365,30 +366,30 @@ const iceCandidateFromProto = (i: ICECandidate) => { | |
const candidate: RTCIceCandidateInit = { | ||
candidate: i.candidate, | ||
}; | ||
if (i.sdpMid) { | ||
if (i.sdpMid !== undefined) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the fix. We we were excluding the right properties because some of them were falsey |
||
candidate.sdpMid = i.sdpMid; | ||
} | ||
if (i.sdpmLineIndex) { | ||
if (i.sdpmLineIndex !== undefined) { | ||
candidate.sdpMLineIndex = i.sdpmLineIndex; | ||
} | ||
if (i.usernameFragment) { | ||
if (i.usernameFragment !== undefined) { | ||
candidate.usernameFragment = i.usernameFragment; | ||
} | ||
return candidate; | ||
}; | ||
|
||
const iceCandidateToProto = (i: RTCIceCandidateInit) => { | ||
const candidate = new ICECandidate(); | ||
if (i.candidate) { | ||
if (i.candidate !== undefined) { | ||
candidate.candidate = i.candidate; | ||
} | ||
if (i.sdpMid) { | ||
if (i.sdpMid !== undefined && i.sdpMid !== null) { | ||
candidate.sdpMid = i.sdpMid; | ||
} | ||
if (i.sdpMLineIndex) { | ||
if (i.sdpMLineIndex !== undefined && i.sdpMLineIndex !== null) { | ||
candidate.sdpmLineIndex = i.sdpMLineIndex; | ||
} | ||
if (i.usernameFragment) { | ||
if (i.usernameFragment !== undefined && i.usernameFragment !== null) { | ||
candidate.usernameFragment = i.usernameFragment; | ||
} | ||
return candidate; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turning this on with the exception of booleans feels very worth it to me. I've written numerous bugs due to how optionals are checked in a truthy/falsey way.