From 956c28ed3950d66f6e211244eb8a560af1883d02 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Wed, 21 Oct 2020 20:49:27 -0600 Subject: [PATCH] Set the user's ID in LocalStorage --- BrowserStorage.md | 7 +++++++ src/views/GameCode.vue | 1 + src/views/JoinHost.vue | 1 + 3 files changed, 9 insertions(+) diff --git a/BrowserStorage.md b/BrowserStorage.md index 5c02772..7932b9f 100644 --- a/BrowserStorage.md +++ b/BrowserStorage.md @@ -1,8 +1,15 @@ This document details the data stored in localStorage and sessionStorage of the browser. +# Session Storage + | Key | Data Type | Description | --------- | --------- | ------------- | game-code | String | The current game code the player is in, if this is not set, then they are not in a game | is-host | Boolean | If the player is the host of the game or not. | user-name | String | The name of the user in the game. + +# Local Storage + +| Key | Data Type | Description +| --------- | --------- | ------------- | user-id | UUID | The user's ID as assigned by the server. This is used to let players re-join games if/when they need to refresh for whatever reason. This is decided by the server and is sent back to the client to ensure the ID is unique across the system. \ No newline at end of file diff --git a/src/views/GameCode.vue b/src/views/GameCode.vue index e6dd834..2a60249 100644 --- a/src/views/GameCode.vue +++ b/src/views/GameCode.vue @@ -66,6 +66,7 @@ export default { }); return; }; + localStorage.setItem(`user-id`, data.uuid); sessionStorage.setItem(`user-name`, this.username); sessionStorage.setItem(`game-code`, this.game_code); sessionStorage.setItem(`is-host`, false); diff --git a/src/views/JoinHost.vue b/src/views/JoinHost.vue index 4d623b4..d8e8b0f 100644 --- a/src/views/JoinHost.vue +++ b/src/views/JoinHost.vue @@ -42,6 +42,7 @@ export default { sockets: { HostInformation(data) { if (data.success) { + localStorage.setItem(`user-id`, data.uuid) sessionStorage.setItem(`game-code`, data.game_code); sessionStorage.setItem(`is-host`, true); this.$emit(`go-to`, `lobby`);