Merge branch 'master' into tadah
This commit is contained in:
commit
884406416f
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue