Skip to content

Commit

Permalink
improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
endel committed Jan 8, 2017
1 parent fecfb37 commit addbb41
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 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.6.0-alpha.2",
"version": "0.6.0-alpha.3",
"description": "Multiplayer Game Client for the Browser",
"keywords": [
"multiplayer",
Expand Down
13 changes: 11 additions & 2 deletions src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down

0 comments on commit addbb41

Please sign in to comment.