Moved ResponderEvent#reply to HttpResponseController#reply
This commit is contained in:
parent
37b4000da3
commit
154ad3150d
@ -15,8 +15,6 @@ public class ResponderEvent {
|
|||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(ResponderEvent.class);
|
private static final Logger LOG = LoggerFactory.getLogger(ResponderEvent.class);
|
||||||
|
|
||||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
|
||||||
|
|
||||||
private final SimpleAutoResponder responder;
|
private final SimpleAutoResponder responder;
|
||||||
|
|
||||||
private final String appPackageName;
|
private final String appPackageName;
|
||||||
@ -65,13 +63,7 @@ public class ResponderEvent {
|
|||||||
* @param messages The messages you want to send
|
* @param messages The messages you want to send
|
||||||
*/
|
*/
|
||||||
public void reply(String... messages) {
|
public void reply(String... messages) {
|
||||||
ObjectNode object = objectMapper.createObjectNode();
|
responseController.reply(messages);
|
||||||
|
|
||||||
ArrayNode replies = object.withArray("replies");
|
|
||||||
|
|
||||||
for (String message : messages) replies.addObject().put("message", message);
|
|
||||||
|
|
||||||
responseController.text(object.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package de.gnmyt.autoresponder.http.controller;
|
package de.gnmyt.autoresponder.http.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
import com.sun.net.httpserver.HttpExchange;
|
import com.sun.net.httpserver.HttpExchange;
|
||||||
import de.gnmyt.autoresponder.http.Response;
|
import de.gnmyt.autoresponder.http.Response;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -15,6 +18,7 @@ public class HttpResponseController {
|
|||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(HttpResponseController.class);
|
private static final Logger LOG = LoggerFactory.getLogger(HttpResponseController.class);
|
||||||
|
|
||||||
|
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||||
private final Response response = new Response();
|
private final Response response = new Response();
|
||||||
private final HttpExchange exchange;
|
private final HttpExchange exchange;
|
||||||
|
|
||||||
@ -62,6 +66,21 @@ public class HttpResponseController {
|
|||||||
send();
|
send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replies to the response
|
||||||
|
*
|
||||||
|
* @param messages The messages you want to send
|
||||||
|
*/
|
||||||
|
public void reply(String... messages) {
|
||||||
|
ObjectNode object = objectMapper.createObjectNode();
|
||||||
|
|
||||||
|
ArrayNode replies = object.withArray("replies");
|
||||||
|
|
||||||
|
for (String message : messages) replies.addObject().put("message", message);
|
||||||
|
|
||||||
|
text(object.toString());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends the response to the AutoResponder
|
* Sends the response to the AutoResponder
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user