Skip to content

Conversation

ComplexRobot
Copy link

Use case:

room.onClose((code) => {
    // Reconnect on abnormal closure 
    if (code === 1006) {
        client.reconnect(room);
        throw new Error("Reconnecting");
    }
});

My reasoning for adding a new event handler onClose is to not alter the function of existing codebases.

onClose handler will happen when the connection closes before onLeave and will cancel leaving and destroying the room if an error is thrown within the callback.

client.reconnect<T>(room: Room<T>) is a new overload.
It will connect in place to an existing room the user is already connected to, therefore not invalidating the state of the existing room and allowing it to be reused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant