Dynamic lisitngs via MatchmakingBackend.
This commit is contained in:
parent
842015051f
commit
614886fcd7
86
server.js
86
server.js
@ -3,7 +3,7 @@ const BodyParser = require("body-parser");
|
|||||||
const mongodb = require("mongodb");
|
const mongodb = require("mongodb");
|
||||||
const ObjectId = require("mongodb").ObjectID;
|
const ObjectId = require("mongodb").ObjectID;
|
||||||
const CONNECTION_URL = "mongodb+srv://edgenetworknode:yUiWfJBYCGwdRayj@matchnethop.hgxv0xd.mongodb.net/?retryWrites=true&w=majority";
|
const CONNECTION_URL = "mongodb+srv://edgenetworknode:yUiWfJBYCGwdRayj@matchnethop.hgxv0xd.mongodb.net/?retryWrites=true&w=majority";
|
||||||
const DATABASE_NAME = "DelegationRequest";
|
const DATABASE_NAME = "edgecomm";
|
||||||
const COLLECTION_NAME = "nettranslate";
|
const COLLECTION_NAME = "nettranslate";
|
||||||
const sha256 = require('js-sha256');
|
const sha256 = require('js-sha256');
|
||||||
var cors = require('cors');
|
var cors = require('cors');
|
||||||
@ -41,17 +41,79 @@ app.get("/lobby/listall/", async (request, response) => {
|
|||||||
Field LBN[num] breaks down into Lobby Name [Number], this informs the client what the name is of the assosiated lobby
|
Field LBN[num] breaks down into Lobby Name [Number], this informs the client what the name is of the assosiated lobby
|
||||||
Field LBIP[num] breaks down into Lobby IP [Number], this informs the client what the IP is of the assosiated lobby
|
Field LBIP[num] breaks down into Lobby IP [Number], this informs the client what the IP is of the assosiated lobby
|
||||||
*/
|
*/
|
||||||
response.status(200).json({
|
var o_id = new mongodb.ObjectID();
|
||||||
LobbyCount: 4,
|
var ar;
|
||||||
LBN1: "DebugLobbyOne",
|
auth.insertOne({
|
||||||
LBIP1: "xxx.xxx.xxx.xxx",
|
_id : o_id,
|
||||||
LBN2: "DebugLobbyTwo",
|
type: 1,
|
||||||
LBIP2: "xxx.xxx.xxx.xxx",
|
status: false
|
||||||
LBN3: "Ability to post lobbies",
|
})
|
||||||
LBIP3: "xxx.xxx.xxx.xxx",
|
await auth.findOne({_id: o_id}, (err, res) => {
|
||||||
LBN4: "Coming soon! (Just have to figure out the database stuff)",
|
const delay = ms => new Promise(resolve => setTimeout(resolve, ms))
|
||||||
LBIP4: "xxx.xxx.xxx.xxx"
|
const dec = async i => (await delay(200), --i)
|
||||||
});
|
ar = res;
|
||||||
|
const verifyUser = async () => {
|
||||||
|
let responseEnabled = true;
|
||||||
|
let enableLookup = true;
|
||||||
|
let i = 8;
|
||||||
|
let timeout = 7;
|
||||||
|
while(i = await dec(i))
|
||||||
|
try {
|
||||||
|
if (enableLookup) {
|
||||||
|
timeout = timeout - 1;
|
||||||
|
if (timeout > 0) {
|
||||||
|
await auth.findOne({_id: o_id}, (err, res) => {
|
||||||
|
if (res.status) {
|
||||||
|
if (responseEnabled) {
|
||||||
|
timeout = 0;
|
||||||
|
i = 1;
|
||||||
|
if (res.type == 2) {
|
||||||
|
responseEnabled = false;
|
||||||
|
enableLookup = false;
|
||||||
|
response.status(200).json({
|
||||||
|
LBN : res.lobbies,
|
||||||
|
LBIP : res.ip,
|
||||||
|
LobbyCount : res.LobbyCount
|
||||||
|
});
|
||||||
|
res = null;
|
||||||
|
} else {
|
||||||
|
responseEnabled = false;
|
||||||
|
ar = null;
|
||||||
|
res = null;
|
||||||
|
response.status(403).json({
|
||||||
|
Info: "Forbidden",
|
||||||
|
Message: "Something went wrong."
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if (responseEnabled) {
|
||||||
|
response.status(403).json({
|
||||||
|
Info: "Forbidden",
|
||||||
|
Message: "Something went wrong..."
|
||||||
|
});
|
||||||
|
responseEnabled = false;
|
||||||
|
ar = null;
|
||||||
|
res = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
enableLookup = false;
|
||||||
|
res = null;
|
||||||
|
if (responseEnabled) {
|
||||||
|
response.sendStatus(500);
|
||||||
|
}
|
||||||
|
responseEnabled = false;
|
||||||
|
console.log(err);
|
||||||
|
timeout = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
verifyUser();
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
app.get("/lobby/submit/", async (request, response) => {
|
app.get("/lobby/submit/", async (request, response) => {
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user