From f7457bc92d47db1207665b8e5e735f14384c8d7b Mon Sep 17 00:00:00 2001 From: Secret1337 <97087168+secret-pommes@users.noreply.github.com> Date: Wed, 27 Sep 2023 20:17:13 +0200 Subject: [PATCH] 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) --- CloudStorage/DefaultEngine.ini | 19 +++++++- CloudStorage/DefaultInput.ini | 3 ++ README.md | 1 + structure/functions.js | 8 +++- structure/matchmaker.js | 82 ++++++++++++++++++++++++++++++++++ structure/matchmaking.js | 2 +- structure/xmpp.js | 8 +++- 7 files changed, 118 insertions(+), 5 deletions(-) create mode 100644 CloudStorage/DefaultInput.ini create mode 100644 structure/matchmaker.js diff --git a/CloudStorage/DefaultEngine.ini b/CloudStorage/DefaultEngine.ini index 46e8702..895948c 100644 --- a/CloudStorage/DefaultEngine.ini +++ b/CloudStorage/DefaultEngine.ini @@ -8,4 +8,21 @@ ServerPort=80 [OnlineSubsystemMcp.Xmpp Prod] bUseSSL=false ServerAddr="ws://127.0.0.1" -ServerPort=80 \ No newline at end of file +ServerPort=80 + +# Forces fortnite to use the v1 party system to support lawinserver xmpp +[OnlineSubsystemMcp] +bUsePartySystemV2=false + +# Forces fortnite to use the v1 party system to support lawinserver xmpp +[OnlineSubsystemMcp.OnlinePartySystemMcpAdapter] +bUsePartySystemV2=false + +# Fix for XMPP not working on some versions +[XMPP] +bEnableWebsockets=true + +# Fix for long waiting at checking connections to datacenters on Switch & Mobile +[/Script/Qos.QosRegionManager] +NumTestsPerRegion=1 +PingTimeout=0.1 \ No newline at end of file diff --git a/CloudStorage/DefaultInput.ini b/CloudStorage/DefaultInput.ini new file mode 100644 index 0000000..de32b4a --- /dev/null +++ b/CloudStorage/DefaultInput.ini @@ -0,0 +1,3 @@ +[/Script/Engine.InputSettings] ++ConsoleKeys=Tilde # Enables console using the tilde key ++ConsoleKeys=F8 # Enables console using the F8 key \ No newline at end of file diff --git a/README.md b/README.md index e84dee3..8410a79 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ - Purchasable battle pass from Season 2 to Season 10 (Can change) - Discovery Tab - Configurable backend sided in-game events - check out the Events seciton in config.ini for more details +- Joining gameservers using the matchmaker - check out the GameServer seciton in config.ini for more details ## How to use? 1) Install [NodeJS](https://nodejs.org/en/) diff --git a/structure/functions.js b/structure/functions.js index 7c4327a..b372086 100644 --- a/structure/functions.js +++ b/structure/functions.js @@ -1,6 +1,12 @@ const XMLBuilder = require("xmlbuilder"); const uuid = require("uuid"); +async function sleep(ms) { + await new Promise((resolve, reject) => { + setTimeout(resolve, ms); + }) +} + function GetVersionInfo(req) { var memory = { season: 0, @@ -236,7 +242,6 @@ function getContentPages(req) { try { const backgrounds = contentpages.dynamicbackgrounds.backgrounds.backgrounds; const season = `season${memory.season}${memory.season >= 21 ? "00" : ""}`; - console.log(season) backgrounds[0].stage = season; backgrounds[1].stage = season; @@ -354,6 +359,7 @@ function DecodeBase64(str) { } module.exports = { + sleep, GetVersionInfo, getItemShop, getTheater, diff --git a/structure/matchmaker.js b/structure/matchmaker.js new file mode 100644 index 0000000..f825ab0 --- /dev/null +++ b/structure/matchmaker.js @@ -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", + }) + ); + } +}; diff --git a/structure/matchmaking.js b/structure/matchmaking.js index f5c9c76..d3721b0 100644 --- a/structure/matchmaking.js +++ b/structure/matchmaking.js @@ -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://lawinservermatchmaker.herokuapp.com", + "serviceUrl": "ws://127.0.0.1", "ticketType": "mms-player", "payload": "69=", "signature": "420=" diff --git a/structure/xmpp.js b/structure/xmpp.js index e8d8139..23add7f 100644 --- a/structure/xmpp.js +++ b/structure/xmpp.js @@ -3,17 +3,21 @@ 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 started 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 \x1b[31mFAILED\x1b[0m to start hosting (NOTE: This should not affect LawinServer)."); + console.log("XMPP and Matchmaker \x1b[31mFAILED\x1b[0m to start hosting."); }) + global.Clients = []; wss.on('connection', async (ws) => { + if (ws.protocol.toLowerCase() != "xmpp") return matchmaker(ws); + var accountId = ""; var jid = ""; var id = "";