let multiplayer name be set in browser storage rather than fully anonymous

allow-name-for-anon-multiplayer
Dave Conway-Jones 2024-10-11 09:08:17 +01:00
parent 83acc4836b
commit d457c81547
No known key found for this signature in database
GPG Key ID: 1DDB0E91A28C2643
2 changed files with 8 additions and 5 deletions

View File

@ -422,6 +422,9 @@ RED.multiplayer = (function () {
if (location.workspace !== 0) {
connectInfo.location = location
}
if (localStorage.getItem("multiplayer-name") !== undefined && localStorage.getItem("multiplayer-name").length >0) {
connectInfo.name = localStorage.getItem("multiplayer-name");
}
RED.comms.send('multiplayer/connect', connectInfo)
})
RED.comms.subscribe('multiplayer/#', (topic, msg) => {

View File

@ -42,7 +42,7 @@ module.exports = {
let user = opts.user
if (!user || user.anonymous) {
user = user || { anonymous: true }
user.username = `Anon ${Math.floor(Math.random()*100)}`
user.username = opts?.data?.name || `Anon ${Math.floor(Math.random()*100)}`
}
session = {
session: opts.data.session,