-
Notifications
You must be signed in to change notification settings - Fork 144
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
Support ICE restart and signaling reconnect in samples #281
base: develop-pre-2.3.0
Are you sure you want to change the base?
Conversation
@@ -150,6 +150,7 @@ export class SignalingClient extends EventEmitter { | |||
* connection has been closed. | |||
*/ | |||
public close(): void { | |||
console.log("Closing the websocket"); |
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.
Can we make the logging configurable? Currently there is no logs so adding logs might be something customers want to disable
this.open(); | ||
// If reconnect fails | ||
setTimeout(() => { | ||
if (this.readyState !== ReadyState.OPEN) { |
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.
Logic needed to check if close
was already called.
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.
setTimeout returns a timer id, you can use clearTimeout(id) in close
to stop the pending countdown as well
setTimeout(() => { | ||
if (this.readyState !== ReadyState.OPEN) { | ||
if (attempt < maxAttempts) { | ||
console.log("Failed reconnect attempt ", attempt); |
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.
console.log("Failed reconnect attempt ", attempt);
console.log("Failed reconnect attempt ", attempt); | |
console.log("Failed reconnect attempt", attempt); |
Space not needed, this will result in double space
} | ||
}, this.reconnectDelay * (attempt + 1)); // increasing delay | ||
} else { | ||
console.log('Invalid state to invoke reconnect from'); |
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.
Let's also log that invalid state - this.readyState
default: | ||
console.log("No reconnect will be attempted. Just exiting with code", event.code); | ||
this.cleanupWebSocket(); | ||
this.emit('close'); |
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.
Can we also emit the event
as data? Then someone can take this data and take action
this.emit('close'); | |
this.emit('close', event); |
Issue #, if available:
What has changed?
Why was it changed?
How was it changed?
Testing
Master: C SDK, Viewer: JS SDK on Chrome
Master: C SDK, Viewer: JS SDK on Firefox
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.