diff --git a/client/public/game/index.html b/client/public/game/index.html
index 6874ec1..4486eb9 100644
--- a/client/public/game/index.html
+++ b/client/public/game/index.html
@@ -14,6 +14,7 @@
+
@@ -25,6 +26,7 @@
+
Create a Lobby
@@ -37,6 +39,7 @@
+
Join a Lobby
diff --git a/server/index.js b/server/index.js
index 4b04fc0..ad13f80 100644
--- a/server/index.js
+++ b/server/index.js
@@ -4,6 +4,7 @@ const Router = require('./src/router.js');
const Socket = require('./src/socketserver.js');
require('dotenv').config()
+const Crypto = require("crypto");
async function main()
{
diff --git a/server/src/game-registrar.js b/server/src/game-registrar.js
index 5d5e153..6095c0a 100644
--- a/server/src/game-registrar.js
+++ b/server/src/game-registrar.js
@@ -80,7 +80,7 @@ function GetUserByUsername(username)
function RegisterUser(username, ip)
{
// TODO: Don't assume this is unique, even with Crypto, UUIDv4?
- const uid = Crypto.randomBytes(32).toString("hex");
+ const uid = Crypto.randomBytes(8).toString("hex");
// Free up disconnected users with likewise usernames
for (const user in OnlineUsers)
@@ -90,7 +90,7 @@ function RegisterUser(username, ip)
DeRegisterUser(user);
} else
{
- return;
+ return false;
}
}
diff --git a/server/src/lobbies.js b/server/src/lobbies.js
index 5673074..aaf990e 100644
--- a/server/src/lobbies.js
+++ b/server/src/lobbies.js
@@ -9,16 +9,28 @@ LOBBY OBJECT
// PUBLIC, PRIVATE
visibility: 'PUBLIC',
allowspectators: bool,
-
}
NOTES
-
+ - Users can only own one lobby
+ - Lobby UID is "join code", will be much shorter than userid
+ - When inactive will be deleted, unlike users
*/
let Lobbies = [];
+function CheckUserAvailability(ownerid)
+{
+ for (const lobby in Lobbies)
+ if (Lobbies[lobby].ownerid == ownerid) return false;
+ return true;
+}
+
+
function RegisterLobby(ownerid, name, private, spectators)
{
+ if (!CheckUserAvailability(ownerid)) return false;
+
+ const uid = Math.random().toString(36).substring(7).toUpperCase();
}
@@ -29,5 +41,8 @@ function DeRegisterLobby(lobbyid)
module.exports = {
+ CheckUserAvailability: CheckUserAvailability,
+ RegisterLobby: RegisterLobby,
+ DeRegisterLobby: DeRegisterLobby
}