Skip to content

thennothinghappened/gml-web

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gml-web

Complete rewrite of my much earlier project, the equally uncreatively named gamemaker-http-server. Modelled heavily after ExpressJS - though in a much worse and less secure form. Should go without saying not to try and use this for something important, but it's still cool, right.....???

Quickstart

The server needs one object to function, this is just so it can piggyback off the Async Network event.
Create Event:

server = new GMServer();

// middleware (blank 1st argument is global middleware)
server.get(, function(req, res, next) {
   res.write($"your IP is <b>{req.ip}</b> <br>");
   next(req, res);
});

// use the JSON parser:
server.use(, server.json());

// init a route
server.get("/hello", function(req, res) {
   res.send("<h1>Hello!</h1>");
});

// POST route
server.post("/do_thing", function(req, res) {
   res.json({"answer": req.body.number * 2});
})

Async - Networking Event:

if (async_load[? "type"] != network_type_data) {
	return;
}

server.handle(async_load[? "id"], async_load[? "ip"], async_load[? "buffer"]);

Make sure your object is also persistent.

About

Remade version of my GameMaker web server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published