This commit is contained in:
Alessandro Autiero
2024-06-02 15:12:42 +02:00
parent efb508bd0c
commit 5d89a603d7
63 changed files with 1146 additions and 1379 deletions

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

View File

@@ -15,7 +15,7 @@ express.get("/fortnite/api/game/v2/matchmakingservice/ticket/player/*", async (r
res.cookie("currentbuildUniqueId", req.query.bucketId.split(":")[0]);
res.json({
"serviceUrl": "ws://127.0.0.1:8080",
"serviceUrl": "ws://127.0.0.1:80",
"ticketType": "mms-player",
"payload": "69=",
"signature": "420="

View File

@@ -3,10 +3,11 @@ const XMLBuilder = require("xmlbuilder");
const XMLParser = require("xml-parser");
const functions = require("./../structure/functions.js");
const matchmaker = require("./matchmaker.js");
const port = 80;
const wss = new WebSocket({ port: port }, () => console.log("XMPP listening on port", port));
const wss = new WebSocket({ port: port }, () => console.log("XMPP and Matchmaker started listening on port", port));
wss.on("error", (err) => {
console.log("XMPP and Matchmaker \x1b[31mFAILED\x1b[0m to start hosting.");
})
@@ -16,11 +17,9 @@ global.Clients = [];
wss.on('connection', async (ws) => {
ws.on('error', () => {});
if (ws.protocol.toLowerCase() != "xmpp") {
return;
}
if (ws.protocol.toLowerCase() != "xmpp") return matchmaker(ws);
var accountId = "";
var jid = "";
var id = "";
@@ -40,7 +39,7 @@ wss.on('connection', async (ws) => {
.attribute("id", ID)
.attribute("version", "1.0")
.attribute("xml:lang", "en").toString())
if (Authenticated == true) {
ws.send(XMLBuilder.create("stream:features").attribute("xmlns:stream", "http://etherx.jabber.org/streams")
.element("ver").attribute("xmlns", "urn:xmpp:features:rosterver").up()
@@ -73,7 +72,7 @@ wss.on('connection', async (ws) => {
if (decodedBase64 && accountId && decodedBase64.length == 3) {
Authenticated = true;
console.log(`An xmpp client with the account id ${accountId} has logged in.`);
ws.send(XMLBuilder.create("success").attribute("xmlns", "urn:ietf:params:xml:ns:xmpp-sasl").toString());
@@ -273,4 +272,4 @@ function ifJSON(str) {
return false;
}
return true;
}
}