Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void handle(HttpExchange exchange) throws IOException{
- //If it's not a post
- if(!(exchange.getRequestMethod().equals("POST"))) {
- logError(exchange, "Bad Method: "+exchange.getRequestMethod());
- exchange.sendResponseHeaders(HttpURLConnection.HTTP_BAD_METHOD, 0);
- exchange.close();
- return;
- }
- //If it's not casio
- //if(exchange.getRemoteAddress().getAddress().getAddress()!= CASIO){
- // logError(exchange, "Forbidden");
- // exchange.sendResponseHeaders(HttpURLConnection.HTTP_FORBIDDEN, 0);
- // exchange.close();
- // return;
- //}
- BufferedReader body = new BufferedReader(new InputStreamReader(exchange.getRequestBody()));
- //Iterate through the attached lines
- for (String line = body.readLine(); line != null; line = body.readLine()) {
- String[] values= line.split(Character.toString('\u001b'));
- String user=values[1];
- String message= values[2];
- int type= Integer.decode(values[3]);
- switch(type){
- case 0: bot.error(user, message); break;
- case 1: bot.say(user, message); break;
- case 2: bot.channel(user, message); break;
- case 3: bot.action(user, message); break;
- }
- }
- exchange.sendResponseHeaders(HttpURLConnection.HTTP_OK, 0);
- exchange.close();
- }
Add Comment
Please, Sign In to add comment