mirror of
https://github.com/Auties00/Reboot-Launcher.git
synced 2026-01-13 03:02:22 +01:00
9.1.4
This commit is contained in:
77
backend/structure/matchmaker.js
Normal file
77
backend/structure/matchmaker.js
Normal file
@@ -0,0 +1,77 @@
|
||||
const functions = require("./functions.js");
|
||||
|
||||
module.exports = async (ws) => {
|
||||
const ticketId = functions.MakeID().replace(/-/gi, "");
|
||||
const matchId = functions.MakeID().replace(/-/gi, "");
|
||||
const sessionId = functions.MakeID().replace(/-/gi, "");
|
||||
|
||||
Connecting();
|
||||
Waiting();
|
||||
Queued();
|
||||
SessionAssignment();
|
||||
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",
|
||||
})
|
||||
);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user