Skip to content

Commit

Permalink
only 'teardown' serializer on connection close. closes colyseus/schem…
Browse files Browse the repository at this point in the history
  • Loading branch information
endel committed Nov 26, 2020
1 parent 6fa0d82 commit 4ba2be5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
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.14.0",
"version": "0.14.1",
"description": "Colyseus Multiplayer Client for JavaScript/TypeScript",
"author": "Endel Dreyer",
"license": "MIT",
Expand Down
12 changes: 8 additions & 4 deletions src/Room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ export class Room<State= any> {
return;
}

this.onLeave.invoke(e.code)
this.onLeave.invoke(e.code);
this.destroy();
};
this.connection.onerror = (e: CloseEvent) => {
console.warn(`Room, onError (${e.code}): ${e.reason}`);
Expand Down Expand Up @@ -162,9 +163,6 @@ export class Room<State= any> {
}

public removeAllListeners() {
if (this.serializer) {
this.serializer.teardown();
}
this.onJoin.clear();
this.onStateChange.clear();
this.onError.clear();
Expand Down Expand Up @@ -267,6 +265,12 @@ export class Room<State= any> {
}
}

private destroy () {
if (this.serializer) {
this.serializer.teardown();
}
}

private getMessageHandlerKey(type: string | number | typeof Schema): string {
switch (typeof(type)) {
// typeof Schema
Expand Down

0 comments on commit 4ba2be5

Please sign in to comment.