public RequestParser(ServerInfos sInfos) { map.Add("mods", sInfos.getMods); map.Add("players", sInfos.getPlayers); map.Add("uptime", sInfos.getUptime); map.Add("world", sInfos.getWorld); }
public Server(ServerInfos sInfos) { // Creating the request Parser RequestParser rp = new RequestParser(sInfos); // Creating Server httpServer = new HttpServer(); // Implemeting the Request Reveived event httpServer.RequestReceived += (s, rEvent) => { // Getting the path of the URL request String path = rEvent.Context.Request.Path.ToString(); // Spliting on each / Char[] splitList = { '/' }; String[] pathList = path.Split(splitList); // Remove any empty string pathList = pathList.Where(val => val != "").ToArray(); // Get path length int length = pathList.Length; rEvent.Response.Headers.Set("Content-Type", "application/json"); // Writing to the Web browser using (var writer = new StreamWriter(rEvent.Response.OutputStream)) { // Veryfying if the path is valid if (length != 1) { writer.Write("Invalid Path Provided"); } else { // Executing the request rp.Parse(writer, pathList[0]); } } }; }
public ServerDashboard() { sInfos = new ServerInfos(); server = new Server(sInfos); server.Start(); }