Matchmaker & some improvements.

**Changes**

- Added the websocket for matchmaker into the server so you can use the matchmaker again. (more infos in the ReadMe file)
- Added some fixes into the cloudstorage to fix long waiting on nintendo switch & mobile when checking server connection.
- Added support for the F8 key to bring up the console.
- Removed a console.log in functions to clean up the log (no longer showing the season in log for no reason)
This commit is contained in:
Secret1337
2023-09-27 20:17:13 +02:00
committed by GitHub
parent 2ea81cbde5
commit f7457bc92d
7 changed files with 118 additions and 5 deletions

82
structure/matchmaker.js Normal file
View File

@@ -0,0 +1,82 @@
const functions = require("./functions.js");
module.exports = async (ws) => {
// create hashes
const ticketId = functions.MakeID().replace(/-/gi, "");
const matchId = functions.MakeID().replace(/-/gi, "");
const sessionId = functions.MakeID().replace(/-/gi, "");
Connecting();
await functions.sleep(800);
Waiting();
await functions.sleep(1000);
Queued();
await functions.sleep(4000);
SessionAssignment();
await functions.sleep(2000);
Join();
function Connecting() {
ws.send(
JSON.stringify({
payload: {
state: "Connecting",
},
name: "StatusUpdate",
})
);
}
function Waiting() {
ws.send(
JSON.stringify({
payload: {
totalPlayers: 1,
connectedPlayers: 1,
state: "Waiting",
},
name: "StatusUpdate",
})
);
}
function Queued() {
ws.send(
JSON.stringify({
payload: {
ticketId: ticketId,
queuedPlayers: 0,
estimatedWaitSec: 0,
status: {},
state: "Queued",
},
name: "StatusUpdate",
})
);
}
function SessionAssignment() {
ws.send(
JSON.stringify({
payload: {
matchId: matchId,
state: "SessionAssignment",
},
name: "StatusUpdate",
})
);
}
function Join() {
ws.send(
JSON.stringify({
payload: {
matchId: matchId,
sessionId: sessionId,
joinDelaySec: 1,
},
name: "Play",
})
);
}
};