From c16c1e1afc257101d541f0d2618834a76d8db2c5 Mon Sep 17 00:00:00 2001 From: Endel Dreyer Date: Thu, 21 Sep 2023 20:30:53 -0300 Subject: [PATCH] prevent console.warn errors in decentraland. bump version. --- package.json | 2 +- src/Room.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 4434640..c51536a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "colyseus.js", - "version": "0.15.13", + "version": "0.15.14", "description": "Colyseus Multiplayer SDK for JavaScript/TypeScript", "author": "Endel Dreyer", "license": "MIT", diff --git a/src/Room.ts b/src/Room.ts index 83c5d9a..2e49f92 100644 --- a/src/Room.ts +++ b/src/Room.ts @@ -55,7 +55,7 @@ export class Room { (this.serializer as SchemaSerializer).state = new rootSchema(); } - this.onError((code, message) => console.warn(`colyseus.js - onError => (${code}) ${message}`)); + this.onError((code, message) => console.warn?.(`colyseus.js - onError => (${code}) ${message}`)); this.onLeave(() => this.removeAllListeners()); } @@ -73,7 +73,7 @@ export class Room { connection.events.onmessage = Room.prototype.onMessageCallback.bind(room); connection.events.onclose = function (e: CloseEvent) { if (!room.hasJoined) { - console.warn(`Room connection was closed unexpectedly (${e.code}): ${e.reason}`); + console.warn?.(`Room connection was closed unexpectedly (${e.code}): ${e.reason}`); room.onError.invoke(e.code, e.reason); return; } @@ -85,7 +85,7 @@ export class Room { } }; connection.events.onerror = function (e: CloseEvent) { - console.warn(`Room, onError (${e.code}): ${e.reason}`); + console.warn?.(`Room, onError (${e.code}): ${e.reason}`); room.onError.invoke(e.code, e.reason); }; connection.connect(endpoint); @@ -288,7 +288,7 @@ export class Room { this.onMessageHandlers.emit('*', type, message); } else { - console.warn(`colyseus.js: onMessage() not registered for type '${type}'.`); + console.warn?.(`colyseus.js: onMessage() not registered for type '${type}'.`); } }