Merge branch 'master' into tadah

This commit is contained in:
I-Have-An-Issue 2023-02-20 04:52:52 -05:00
commit 884406416f
No known key found for this signature in database
GPG Key ID: E55435DEA0825091
4 changed files with 9 additions and 15 deletions

View File

@ -5,7 +5,7 @@ const RCCService = require("./RCCService.js")
const logger = require("../logger.js") const logger = require("../logger.js")
class Job extends RCCService { class Job extends RCCService {
constructor({ id = randomUUID(), expirationInSeconds = 10, category = 0, cores = 1 } = {}) { constructor({ id = randomUUID(), expirationInSeconds = 60, category = 0, cores = 1 } = {}) {
super() super()
this.id = id this.id = id
this.expirationInSeconds = expirationInSeconds this.expirationInSeconds = expirationInSeconds

View File

@ -136,11 +136,6 @@ class RenderJob extends Job {
} }
async RenderPlace(id) { async RenderPlace(id) {
const response = await axios(`${process.env.BASE_URL}/API/Game/${id}?t=${process.env.ARBITER_TOKEN}`).catch((_) => reject(_))
const { server_token, server_port, server_owner_id } = response.data
this.id = server_token
const running = this.started const running = this.started
if (!running) { if (!running) {
const started = await this.Start() const started = await this.Start()
@ -166,6 +161,7 @@ class RenderJob extends Job {
{ type: "LUA_TSTRING", value: process.env.BASE_URL }, { type: "LUA_TSTRING", value: process.env.BASE_URL },
{ type: "LUA_TNUMBER", value: id }, { type: "LUA_TNUMBER", value: id },
{ type: "LUA_TSTRING", value: process.env.ARBITER_TOKEN },
], ],
}, },
}).catch((e) => false) }).catch((e) => false)

View File

@ -13,7 +13,7 @@ exports.tcp = () => {
exports.udp = () => { exports.udp = () => {
return new Promise((resolve) => { return new Promise((resolve) => {
const server = dgram.createSocket() const server = dgram.createSocket("udp4")
server.bind(Math.random() * (60_000 - 50_000) + 50_000, () => { server.bind(Math.random() * (60_000 - 50_000) + 50_000, () => {
const port = server.address().port const port = server.address().port
server.close((err) => resolve(port)) server.close((err) => resolve(port))

View File

@ -3,16 +3,14 @@ const app = express.Router()
const RenderJob = require("../../lib/classes/RenderJob.js") const RenderJob = require("../../lib/classes/RenderJob.js")
// app.get("/:id", async (request, response) => { app.get("/:id", async (request, response) => {
// const job = new RenderJob() const { params, query } = request
// const result = await job.RenderPlace(request.params.id, process.env.RENDER_BASE64).catch((_) => _) const job = new RenderJob()
// if (result?.message) return response.status(500).json({ error: result.message }) const game = await job.RenderPlace(params.id).catch((_) => _)
// else return response.end(result) if (game?.message) return response.status(500).json({ error: game.message })
// })
app.get("*", (request, response) => { return response.end(game)
response.status(501).end("Not Implemented")
}) })
module.exports = app module.exports = app