Hi there,
I’m currently working on a “little” project. I won’t go into detail about what it is exactly, but I’ll explain the use case. The website provides a way to protect the source of Lua code for games. It does this by running the code in a sandboxed environment on a VPS (we can’t do it on a worker because of the memory limit) and then, when the code needs to interact with the game, you send little snippets of more Lua code for execution on the game.
Now, here’s how the system works. First, when the game starts, it sends a request to our Cloudflare Worker that takes the cf-connecting-ip
header to verify the request is really from the game server. The worker then tells the VPS to start executing the code. Now, let me give you a little pseudo-code snippet of what the Lua code might be.
-- Listens for when a part in the game is touched
local functions = marketplace.functions()
local part = functions.getObject('workspace.Part')
functions.registerEvent('Touched', part, function()
print('Part touched')
end)
Now, this code doesn’t look like much, but behind the scenes, it’s doing a lot. First, the getObject
method actually sends a request to the game server telling it to return that part. Then, registerEvent
tells the game server to send a request to the worker everytime that part is touched.
Now that I have the use case explained, let me explain the issue. The game sends the initial request telling the server it has started, which then tells the VPS to start executing the code. The VPS might then tell the game to listen for a part to be touched and then the game sends a request back to the worker when the part was touched which then has to tell the VPS that the part was touched to execute the callback.
There’s a lot going on there, but I need to find the most efficient way for all of those different requests to communicate with each other. I want that first initial request to create some sort of function that runs until the game ends which all the other requests feed into so it can handle everything for that game in one central place.
Not sure if this made any sense, I can try and explain it some more if you need me to.