From 6ad1df5a35287f80e540033352c733ede484c38a Mon Sep 17 00:00:00 2001 From: Dave Date: Tue, 16 Mar 2021 15:14:51 +0000 Subject: [PATCH] updated the send and update sockets methods for player pronouns to pass through a flag when the pronoun is updated from the sockets to stop the update being broadcast again and causing infinite loops of sockets messages being sent. This also simplifys from the previous loop prevention functionality. --- src/store/socket.js | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/store/socket.js b/src/store/socket.js index a69ab24..3f9adbb 100644 --- a/src/store/socket.js +++ b/src/store/socket.js @@ -489,35 +489,35 @@ class LiveSession { * Publish a player pronouns update * @param player * @param value + * @param fromSockets */ - sendPlayerPronouns({ player, value }) { + sendPlayerPronouns({ player, value, fromSockets }) { //send pronoun only for the seated player or storyteller - if (this._isSpectator && this._store.state.session.playerId !== player.id) + //Do not re-send pronoun data for an update that was recieved from the sockets layer + if ( + fromSockets || + (this._isSpectator && this._store.state.session.playerId !== player.id) + ) return; const index = this._store.state.players.players.indexOf(player); - this._send("pronouns", [index, value, !this._isSpectator]); + this._send("pronouns", [index, value]); } /** - * Update a pronouns based on incoming data. Player only. + * Update a pronouns based on incoming data. * @param index * @param value - * @param fromSt * @private */ - _updatePlayerPronouns([index, value, fromST]) { + _updatePlayerPronouns([index, value]) { const player = this._store.state.players.players[index]; - if ( - player && - (fromST || this._store.state.session.playerId !== player.id) && - player.pronouns !== value - ) { - this._store.commit("players/update", { - player, - property: "pronouns", - value - }); - } + + this._store.commit("players/update", { + player, + property: "pronouns", + value, + fromSockets: true + }); } /**