-
Notifications
You must be signed in to change notification settings - Fork 69
HTTP status page #207
Description
We could have an optional system plugin library which uses HttpListener to produce a basic MUD stats page. It could respond to specific request pattern with a basic HTML page, including basic health stats, be configured to report number of online players, and so on. (Basically could report similar information as might get reported with MSSP #196 .) Ideally the architecture should be pretty non-invasive: If the plugin library is present, the system runs at MUD startup, and provides the capabilities. It would be good to have some basic configuration support (app.config values?) to do things like deviate from the default port number.
There might also be other super lightweight HTTP responder options to look into other than HttpListener too. I believe this one would require admin rights to listen to something other than localhost, which might not be great for some hosting contexts? Maybe that doesn't matter, and starting with something simple is good enough, and others could build similar plugins if more advanced requirements are desired. We could at least document our intentions and mission on this front though.
A quick spike showed HttpListener does not need a lot of setup, e.g. this worked from a basic console app:
HttpListener listener = new();
listener.Prefixes.Add("http://localhost:8080/");
listener.Start();
while (true)
{
HttpListenerContext context = listener.GetContext(); // Wait for next request.
var response = context.Response;
response.OutputStream.Write(Encoding.UTF8.GetBytes("<HTML><BODY>Hello world!</BODY></HTML>"));
response.OutputStream.Close();
}