commit | author | age
|
0c8d27
|
1 |
package de.uhilger.avdirektor.handler; |
U |
2 |
|
|
3 |
import com.sun.net.httpserver.HttpExchange; |
|
4 |
import com.sun.net.httpserver.HttpHandler; |
|
5 |
import java.io.IOException; |
|
6 |
import java.io.OutputStream; |
|
7 |
import java.util.Map; |
|
8 |
import java.util.logging.Level; |
|
9 |
import java.util.logging.Logger; |
|
10 |
|
|
11 |
/** |
|
12 |
* |
|
13 |
* @author ulrich |
|
14 |
*/ |
cc2a32
|
15 |
public class CmdHandler extends OMXPlayer implements HttpHandler { |
0c8d27
|
16 |
|
U |
17 |
private static final Logger logger = Logger.getLogger(CmdHandler.class.getName()); |
|
18 |
|
cc2a32
|
19 |
private String cmd; |
0c8d27
|
20 |
|
cc2a32
|
21 |
public CmdHandler(String cmd) { |
U |
22 |
this.cmd = cmd; |
|
23 |
} |
|
24 |
|
|
25 |
public void setCmd(String cmd) { |
|
26 |
this.cmd = cmd; |
|
27 |
} |
|
28 |
|
|
29 |
public String getCmd(String cmd) { |
|
30 |
return this.cmd; |
|
31 |
} |
0c8d27
|
32 |
|
U |
33 |
@Override |
|
34 |
public void handle(HttpExchange t) throws IOException { |
|
35 |
logger.log(Level.FINE, "RequestURI: {0}", t.getRequestURI().toString()); |
|
36 |
Map map = getQueryMap(t); |
|
37 |
|
a7f0a1
|
38 |
String antwort = this.kommando(cmd); |
0c8d27
|
39 |
logger.log(Level.FINE, antwort); |
U |
40 |
|
cc2a32
|
41 |
String response = getResponseString(map, cmd, antwort); |
0c8d27
|
42 |
t.sendResponseHeaders(200, response.length()); |
U |
43 |
OutputStream os = t.getResponseBody(); |
|
44 |
os.write(response.getBytes()); |
|
45 |
os.close(); |
|
46 |
} |
|
47 |
|
|
48 |
} |