Support ICE restart and signaling reconnect in samples#281
Draft
disa6302 wants to merge 3 commits intodevelop-pre-2.3.0from
Draft
Support ICE restart and signaling reconnect in samples#281disa6302 wants to merge 3 commits intodevelop-pre-2.3.0from
disa6302 wants to merge 3 commits intodevelop-pre-2.3.0from
Conversation
sirknightj
reviewed
Jan 3, 2024
| * connection has been closed. | ||
| */ | ||
| public close(): void { | ||
| console.log("Closing the websocket"); |
Contributor
There was a problem hiding this comment.
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) { |
Contributor
There was a problem hiding this comment.
Logic needed to check if close was already called.
Contributor
There was a problem hiding this comment.
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); |
Contributor
There was a problem hiding this comment.
console.log("Failed reconnect attempt ", attempt);
Suggested change
| 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'); |
Contributor
There was a problem hiding this comment.
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'); |
Contributor
There was a problem hiding this comment.
Can we also emit the event as data? Then someone can take this data and take action
Suggested change
| this.emit('close'); | |
| this.emit('close', event); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.