commit | author | age
|
60719c
|
1 |
/* |
U |
2 |
AV-Direktor - Control OMXPlayer on Raspberry Pi via HTTP |
|
3 |
Copyright (C) 2021 Ulrich Hilger |
|
4 |
|
|
5 |
This program is free software: you can redistribute it and/or modify |
|
6 |
it under the terms of the GNU Affero General Public License as |
|
7 |
published by the Free Software Foundation, either version 3 of the |
|
8 |
License, or (at your option) any later version. |
|
9 |
|
|
10 |
This program is distributed in the hope that it will be useful, |
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
GNU Affero General Public License for more details. |
|
14 |
|
|
15 |
You should have received a copy of the GNU Affero General Public License |
|
16 |
along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
17 |
*/ |
|
18 |
|
8e2038
|
19 |
package de.uhilger.avdirektor.handler; |
U |
20 |
|
|
21 |
import com.sun.net.httpserver.HttpExchange; |
|
22 |
import com.sun.net.httpserver.HttpHandler; |
|
23 |
import de.uhilger.avdirektor.App; |
|
24 |
import java.io.IOException; |
|
25 |
import java.io.OutputStream; |
|
26 |
import java.util.logging.Logger; |
|
27 |
|
|
28 |
/** |
|
29 |
* |
|
30 |
* @author ulrich |
|
31 |
*/ |
e499f8
|
32 |
public class StopServerHandler extends OMXPlayer implements HttpHandler { |
8e2038
|
33 |
|
U |
34 |
@Override |
|
35 |
public void handle(HttpExchange exchange) throws IOException { |
|
36 |
Logger.getLogger(StopServerHandler.class.getName()).info(exchange.getRequestURI().toString()); |
0af362
|
37 |
this.kommando(CMD_STOP); |
8e2038
|
38 |
String response = "Server stopped"; |
U |
39 |
exchange.sendResponseHeaders(200, response.length()); |
|
40 |
OutputStream os = exchange.getResponseBody(); |
|
41 |
os.write(response.getBytes()); |
ac1194
|
42 |
os.flush(); |
8e2038
|
43 |
os.close(); |
U |
44 |
Logger.getLogger(StopServerHandler.class.getName()).info("stopping app."); |
|
45 |
App.stop(); |
|
46 |
//exchange.getHttpContext().getServer().stop(5); |
|
47 |
} |
|
48 |
|
|
49 |
|
|
50 |
} |