Skip to content
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

Add in place reconnection functionality for auto-reconnect on "abnormal closure" (error 1006) #146

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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