mirror of
https://github.com/Lawin0129/LawinServer.git
synced 2026-01-13 02:42:22 +01:00
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:
82
structure/matchmaker.js
Normal file
82
structure/matchmaker.js
Normal 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",
|
||||
})
|
||||
);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user