Skip to content

Commit

Permalink
introduce .onLeave(code, reason)
Browse files Browse the repository at this point in the history
  • Loading branch information
endel committed Feb 26, 2025
1 parent 625e27f commit 2c860ce
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@

document.addEventListener("mousemove", onmousemove);

room.onLeave(function() {
console.log("LEFT ROOM", arguments);
room.onLeave(function(code, reason) {
console.log("LEFT ROOM",{code, reason});
document.removeEventListener("mousemove", onmousemove);
});

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "colyseus.js",
"version": "0.16.3",
"version": "0.16.4",
"description": "Colyseus Multiplayer SDK for JavaScript/TypeScript",
"author": "Endel Dreyer",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions src/Room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class Room<State= any> {
// Public signals
public onStateChange = createSignal<(state: State) => void>();
public onError = createSignal<(code: number, message?: string) => void>();
public onLeave = createSignal<(code: number) => void>();
public onLeave = createSignal<(code: number, reason?: string) => void>();
protected onJoin = createSignal();

public serializerId: string;
Expand Down Expand Up @@ -85,7 +85,7 @@ export class Room<State= any> {
if (e.code === CloseCode.DEVMODE_RESTART && devModeCloseCallback) {
devModeCloseCallback();
} else {
room.onLeave.invoke(e.code);
room.onLeave.invoke(e.code, e.reason);
room.destroy();
}
};
Expand Down

0 comments on commit 2c860ce

Please sign in to comment.