Files
LawinServer/structure/matchmaker.js
Secret1337 f7457bc92d 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)
2023-09-27 20:17:13 +02:00

83 lines
1.6 KiB
JavaScript

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",
})
);
}
};