From addbb4152168daf62910f93d326aa07eafa57eac Mon Sep 17 00:00:00 2001 From: Endel Dreyer Date: Sun, 8 Jan 2017 15:32:41 +0100 Subject: [PATCH] improve error handling --- package.json | 2 +- src/Client.ts | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index a287d9a..572a8de 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "colyseus.js", - "version": "0.6.0-alpha.2", + "version": "0.6.0-alpha.3", "description": "Multiplayer Game Client for the Browser", "keywords": [ "multiplayer", diff --git a/src/Client.ts b/src/Client.ts index 162b695..dc04137 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -90,9 +90,18 @@ export class Client extends WebSocketClient { } else if (code == Protocol.JOIN_ERROR) { let room = this.rooms[ roomId ]; - delete this.rooms[ roomId ]; - room.onError.dispatch(message[2]); + console.error("server error:", message[2]); + + if (room) { + // room-related error + room.onError.dispatch(message[2]); + + } else { + // general error + this.onError.dispatch(message[2]); + } + } else if (code == Protocol.LEAVE_ROOM) {