changed how id's work
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
|
||||
<div id="connection-state"></div>
|
||||
<p>
|
||||
|
||||
|
||||
<div id="lobbies" style="display:none">
|
||||
<input type="button" value="Create Lobby" onclick="createLobby()">
|
||||
@@ -25,6 +26,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="lobby-create" style="display:none">
|
||||
<h3>Create a Lobby</h3>
|
||||
<input type="text" id="" placeholder="name">
|
||||
@@ -37,6 +39,7 @@
|
||||
<input type="button" value="back" onclick="back()">
|
||||
</div>
|
||||
|
||||
|
||||
<div id="lobby-join" style="display:none">
|
||||
<h3>Join a Lobby</h3>
|
||||
<input type="text" id="" placeholder="lobby code">
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user