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; } });