Add a check to make sure that the player's socket also isn't undefined

This commit is contained in:
Oliver Akins 2022-03-08 13:26:44 -06:00
parent f4396a1c42
commit 330125efbe
No known key found for this signature in database
GPG key ID: 3C2014AF9457AF99

View file

@ -20,7 +20,7 @@ export class Player {
/** The socket that can be used to communicate directly with the player */ /** The socket that can be used to communicate directly with the player */
get socket() { return this._socket }; get socket() { return this._socket };
set socket(value: Socket) { set socket(value: Socket) {
if (!this._socket.connected) { if (!this._socket?.connected) {
this._socket = value; this._socket = value;
} else { } else {
throw Error("Cannot overwrite a player's socket that is connected."); throw Error("Cannot overwrite a player's socket that is connected.");