Closed
Description
I'd like to propose a change in the API, to allow restructuring of the match-making process, and avoid unexpected issues during its process.
The proposed API here is not final. I'd love to hear your thoughts about it!
Current behaviour
Currently, the match-making process may cause unexpected issues due to async rooms being disposed in the middle of the process, like #174
On the client-side, the room instance is immediately created even though the room might not be successfully created.
const room = client.join("my_room", { /* options */ });
room.onJoin.add(() => console.log("joined successfully!"))
room.onError.add(() => console.log("room couldn't be created?"))
- This API can be confusing since both room creation errors, and regular room errors are dispatched into the same handler, without a differentiation between them.
- It's not possible to determine whether a join error was caused by wrong credentials (
onAuth
) or a bug in the server.
Desired behaviour
The server can make extra-checks during the match-making process to avoid this error (#174), and provide better error handling in the client-side.
client.matchmake("my_room", {/* options */}, (err, room) => {
if (err) {
console.log("match-making error: couldn't join into 'my_room'");
console.log("reason:", err)
return;
}
room.onJoin.add(() => console.log("joined successfully!"));
room.onError.add(() => console.log("only room errors here"));
});
Version 1.0.0
As this is a big change in the API, I'm planning to have this on version 1.0.0
.