示例#1
0
 public RequestParser(ServerInfos sInfos)
 {
     map.Add("mods", sInfos.getMods);
     map.Add("players", sInfos.getPlayers);
     map.Add("uptime", sInfos.getUptime);
     map.Add("world", sInfos.getWorld);
 }
示例#2
0
        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]);
                    }
                }
            };
        }
示例#3
0
 public ServerDashboard()
 {
     sInfos = new ServerInfos();
     server = new Server(sInfos);
     server.Start();
 }