-
Notifications
You must be signed in to change notification settings - Fork 1
Conversation
src/reconnection.ts
Outdated
@@ -49,6 +49,7 @@ export class ReconnectManager<PeerMetadata, TrackMetadata> { | |||
private reconnectTimeoutId: NodeJS.Timeout | null = null; | |||
private reconnectFailedNotificationSend: boolean = false; | |||
private ongoingReconnection: boolean = false; | |||
private reconnectionStartedNotificationSend: boolean = false; |
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.
private reconnectionStartedNotificationSend: boolean = false; | |
private reconnectionStartedNotificationSent: boolean = false; |
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.
Also there are now three boolean variables like this: reconnectFailedNotificationSend
and reconnectionStartedNotificationSend
and ongoingReconnection
I wonder if we can merge them into one variable that keeps the current state of reconnection?
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.
I've removed these variables and introduced a simple state machine
export type ReconnectionStatus = 'reconnecting' | 'idle' | 'error';
src/FishjamClient.ts
Outdated
/** Emitted when the process of reconnection starts */ | ||
reconnectionStarted: () => void; | ||
|
||
/** Emitted when on successful reconnection */ |
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.
broken english
src/FishjamClient.ts
Outdated
reconnected: () => void; | ||
|
||
/** Emitted when the maximum number of reconnection retries is reached */ | ||
reconnectionFailed: () => void; |
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.
Maybe sth like reconnectionRetriesLimitReached
? 🤔
src/FishjamClient.ts
Outdated
if (this.status === 'initialized') { | ||
this.disconnect(); | ||
await this.disconnect(); |
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.
Maybe it would be worth to investigate if this rule can be used to detect issues like this one
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.
In general, I absolutely agree with you; we should add this rule. What's more, we should make more functions async, like connect, but I don't want to introduce such changes in this PR.
In this particular line, it's a relic of my previous attempts. The disconnect()
function is not async.
src/reconnection.ts
Outdated
}; | ||
} | ||
|
||
public getOngoingReconnectionStatus(): boolean { |
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.
WDYT
public getOngoingReconnectionStatus(): boolean { | |
public isReconnecting(): boolean { |
for await (const element of this.lastLocalEndpoint.tracks) { | ||
const [_, track] = element; |
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.
I would like to discuss this part of code, as I would like to understand something.
Description
This PR:
reconnectionStarted
,reconnected
,reconnectionFailed
ongoingReconnection
statusRTCPeerConnection
after successful reconnectionpeer already connected
auth join reasonMotivation and Context
It fixes the reconnection mechanism when the user changes the network (e.g., from Wi-Fi to a hotspot).
Types of changes