Game thumbnails, randport.udp() should be on udp4

This commit is contained in:
I-Have-An-Issue 2023-02-20 04:52:40 -05:00
parent 7da5877d58
commit 6d1e6401e3
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")
class Job extends RCCService {
constructor({ id = randomUUID(), expirationInSeconds = 10, category = 0, cores = 1 } = {}) {
constructor({ id = randomUUID(), expirationInSeconds = 60, category = 0, cores = 1 } = {}) {
super()
this.id = id
this.expirationInSeconds = expirationInSeconds

View File

@ -136,11 +136,6 @@ class RenderJob extends Job {
}
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
if (!running) {
const started = await this.Start()
@ -166,6 +161,7 @@ class RenderJob extends Job {
{ type: "LUA_TSTRING", value: process.env.BASE_URL },
{ type: "LUA_TNUMBER", value: id },
{ type: "LUA_TSTRING", value: process.env.ARBITER_TOKEN },
],
},
}).catch((e) => false)

View File

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

View File

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