From 60fab2efe05a1b9564804cb28f0fed1577af7be3 Mon Sep 17 00:00:00 2001 From: Dave Date: Wed, 27 Jan 2021 20:33:38 +0000 Subject: [PATCH] adding code to transmit changes to player pronoun --- src/store/socket.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/store/socket.js b/src/store/socket.js index 3c29e1c..32e5b02 100644 --- a/src/store/socket.js +++ b/src/store/socket.js @@ -170,6 +170,9 @@ class LiveSession { case "bye": this._handleBye(params); break; + case "pronoun": + this._updatePlayerPronoun(params); + break; } } @@ -461,6 +464,24 @@ class LiveSession { } } + sendPlayerPronoun({ player, pronoun }) { + if (!this._isSpectator) return; + const index = this._store.state.players.players.indexOf(player); + this._send("pronoun", { index, pronoun }); + } + + /** + * Update a pronoun based on incoming data. Player only. + * @param index + * @param pronoun + * @private + */ + _updatePlayerPronoun({ index, pronoun }) { + const player = this._store.state.players.players[index]; + if (!player) return; + this._store.commit("players/setPronoun", { player, pronoun }); + } + /** * Handle a ping message by another player / storyteller * @param isSpectator @@ -789,6 +810,9 @@ export default store => { case "players/update": session.sendPlayer(payload); break; + case "players/setPronoun": + session.sendPlayerPronoun(payload); + break; } });