commit | author | age
|
8e2038
|
1 |
package de.uhilger.avdirektor.handler; |
U |
2 |
|
|
3 |
import com.sun.net.httpserver.HttpExchange; |
|
4 |
import com.sun.net.httpserver.HttpHandler; |
|
5 |
import de.uhilger.avdirektor.App; |
|
6 |
import java.io.IOException; |
|
7 |
import java.io.OutputStream; |
|
8 |
import java.util.logging.Logger; |
|
9 |
|
|
10 |
/** |
|
11 |
* |
|
12 |
* @author ulrich |
|
13 |
*/ |
e499f8
|
14 |
public class StopServerHandler extends OMXPlayer implements HttpHandler { |
8e2038
|
15 |
|
U |
16 |
@Override |
|
17 |
public void handle(HttpExchange exchange) throws IOException { |
|
18 |
Logger.getLogger(StopServerHandler.class.getName()).info(exchange.getRequestURI().toString()); |
0af362
|
19 |
this.kommando(CMD_STOP); |
8e2038
|
20 |
String response = "Server stopped"; |
U |
21 |
exchange.sendResponseHeaders(200, response.length()); |
|
22 |
OutputStream os = exchange.getResponseBody(); |
|
23 |
os.write(response.getBytes()); |
ac1194
|
24 |
os.flush(); |
8e2038
|
25 |
os.close(); |
U |
26 |
Logger.getLogger(StopServerHandler.class.getName()).info("stopping app."); |
|
27 |
App.stop(); |
|
28 |
//exchange.getHttpContext().getServer().stop(5); |
|
29 |
} |
|
30 |
|
|
31 |
|
|
32 |
} |