public class WebServerManager
extends java.lang.Object
implements com.sun.net.httpserver.HttpHandler
| Modifier and Type | Field and Description |
|---|---|
private com.sun.net.httpserver.HttpServer |
server
The HTTP server.
|
| Constructor and Description |
|---|
WebServerManager(int port)
Creates and starts the web server on given port.
|
| Modifier and Type | Method and Description |
|---|---|
void |
handle(com.sun.net.httpserver.HttpExchange httpExchange)
Handles incoming requests.
|
private static void |
sendFileResponse(com.sun.net.httpserver.HttpExchange httpExchange,
java.io.File response)
Sends the given zip file as response to the request.
|
private static void |
sendOverview(com.sun.net.httpserver.HttpExchange httpExchange)
Sends a response to the request, containing links to the other requests.
|
private static void |
sendResourcepack(com.sun.net.httpserver.HttpExchange httpExchange)
Sends a response to the request, containing the resourcepack from the data folder.
|
private static void |
sendStaff(com.sun.net.httpserver.HttpExchange httpExchange)
Sends a response to the request, containing a list of all staff members.
|
private static void |
sendStats(com.sun.net.httpserver.HttpExchange httpExchange)
Sends a response to the request, containing general gameplay statistics.
|
private static void |
sendSystemAnalytics(com.sun.net.httpserver.HttpExchange httpExchange)
Sends a response to the request, containing system info and usage.
|
private static void |
sendTextResponse(com.sun.net.httpserver.HttpExchange httpExchange,
java.lang.String response,
boolean isHtml)
Sends the given text response to the request.
|
void |
stop()
Stops the web server.
|
public WebServerManager(int port)
port - The port for web requests.public void stop()
public void handle(com.sun.net.httpserver.HttpExchange httpExchange)
throws java.io.IOException
handle in interface com.sun.net.httpserver.HttpHandlerhttpExchange - The encapsulated HTTP request.java.io.IOExceptionprivate static void sendResourcepack(com.sun.net.httpserver.HttpExchange httpExchange)
httpExchange - The encapsulated HTTP request.private static void sendSystemAnalytics(com.sun.net.httpserver.HttpExchange httpExchange)
httpExchange - The encapsulated HTTP request.private static void sendStats(com.sun.net.httpserver.HttpExchange httpExchange)
httpExchange - The encapsulated HTTP request.private static void sendStaff(com.sun.net.httpserver.HttpExchange httpExchange)
httpExchange - The encapsulated HTTP request.private static void sendOverview(com.sun.net.httpserver.HttpExchange httpExchange)
httpExchange - The encapsulated HTTP request.private static void sendTextResponse(com.sun.net.httpserver.HttpExchange httpExchange,
java.lang.String response,
boolean isHtml)
throws java.io.IOException
httpExchange - The encapsulated HTTP request.response - The response to send.isHtml - If the content type is a HTML.java.io.IOException - Error while writing response.private static void sendFileResponse(com.sun.net.httpserver.HttpExchange httpExchange,
java.io.File response)
throws java.io.IOException
httpExchange - The encapsulated HTTP request.response - The response to send.java.io.IOException - Error while writing response.