+ handle_player(request, response) {
+ const player = this.find_player(request.session);
+ const name = request.body.name;
+ const team = request.body.team;
+ var updated = false;
+ if (! player) {
+ response.sendStatus(404);
+ return;
+ }
+
+ if (name && (player.name !== name)) {
+ player.name = name;
+
+ /* In addition to setting the name within this game's player
+ * object, also set the name in the session. */
+ request.session.nickname = name;
+ request.session.save();
+
+ updated = true;
+ }
+
+ if (team !== null && (player.team !== team) &&
+ (team === "" || this.teams.includes(team)))
+ {
+ player.team = team;
+
+ updated = true;
+ }
+
+ if (updated)
+ this.broadcast_event("player-update", player.info_json());
+
+ response.send("");
+ }
+