commit | author | age
|
0c8d27
|
1 |
/* |
60719c
|
2 |
AV-Direktor - Control OMXPlayer on Raspberry Pi via HTTP |
U |
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 |
|
0c8d27
|
19 |
package de.uhilger.avdirektor.handler; |
U |
20 |
|
|
21 |
import com.sun.net.httpserver.HttpExchange; |
b5cc80
|
22 |
import java.io.IOException; |
U |
23 |
import java.io.OutputStream; |
0c8d27
|
24 |
import java.util.logging.Level; |
U |
25 |
import java.util.logging.Logger; |
|
26 |
|
|
27 |
/** |
|
28 |
* |
|
29 |
* @author ulrich |
|
30 |
*/ |
e499f8
|
31 |
public class PingHandler extends CmdHandler { |
0c8d27
|
32 |
|
U |
33 |
private static final Logger logger = Logger.getLogger(PingHandler.class.getName()); |
|
34 |
|
e499f8
|
35 |
public PingHandler(String cmd) { |
U |
36 |
super(cmd); |
|
37 |
} |
|
38 |
|
b5cc80
|
39 |
protected String process(HttpExchange t, String params) { |
U |
40 |
logger.log(Level.FINE, cmd); |
|
41 |
return cmd; |
|
42 |
} |
|
43 |
|
|
44 |
protected void sendResponse(HttpExchange t, String cmd, String antwort) throws IOException { |
|
45 |
t.sendResponseHeaders(200, antwort.length()); |
0c8d27
|
46 |
OutputStream os = t.getResponseBody(); |
b5cc80
|
47 |
os.write(antwort.getBytes()); |
0c8d27
|
48 |
os.close(); |
U |
49 |
} |
|
50 |
|
|
51 |
} |