voxeet / voxeet-sdk-web

The Dolby.io Communications SDK for Web.
https://www.npmjs.com/package/@voxeet/voxeet-web-sdk
Other
4 stars 2 forks source link

Token expiry and Resuming after disconnection of bad internet connection #8

Closed azeemgujjar closed 1 year ago

azeemgujjar commented 2 years ago

Hello,

  1. I found that after token expired, conference also end which is annoying for users while conference is in progress. I didn't find any example or refresh token case in documentation, can you please clarify how can we refresh token before expiry and pass it to running conference to resume conference without interruption?

  2. Also in case if any user disconnected due to internet connection or any other reason such as (ErrorWebSocketError, PeerConnectionDisconnectedError) issue, how can we resume or retry connectivity without refreshing the whole site?

FabienLavocat commented 2 years ago
  1. In order to refresh the access token, you can simply use the callback from the initializeToken function from the SDK. Check out this documentation section to refresh the access token. The SDK will automatically run the callback when a new access token is needed so you don't have to worry about refreshing it.

  2. When an internet connection issue occurs, the SDK will trigger some error events, but will automatically try to restore the connection. If, after 20 seconds the SDK cannot restore the connection to the conference, then the participant will be disconnected. In this situation, the SDK will trigger the event left. In your application, you can capture this event and rejoin the conference automatically without having to refresh the browser tab.

azeemgujjar commented 2 years ago

Can you please share some sample code how to rejoin incase connection lost after 20 seconds?

FabienLavocat commented 2 years ago

I don't have a complete code ready to use as it will depends mostly on your application, but the idea is similar to that:

// Capture the left event
VoxeetSDK.conference.on("left", async () => {
    // re-join the conference previously joined
    // Note: you might have to check before re-joining that the end user has not left the conference on purpose (use a simple flag for that when the user clicks on a leave button)
    await VoxeetSDK.conference.join(conference, { constraints: constraints });
});