diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAPI_V1_Controller.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAPI_V1_Controller.java index e0d0d0a6..3cac55f3 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAPI_V1_Controller.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAPI_V1_Controller.java @@ -279,48 +279,26 @@ public class ExamAPI_V1_Controller { method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - public CompletableFuture> ping( + public void ping( @RequestHeader(name = API.EXAM_API_SEB_CONNECTION_TOKEN, required = true) final String connectionToken, @RequestParam(name = API.EXAM_API_PING_TIMESTAMP, required = true) final long timestamp, - @RequestParam(name = API.EXAM_API_PING_NUMBER, required = false) final int pingNumber) { + @RequestParam(name = API.EXAM_API_PING_NUMBER, required = false) final int pingNumber, + final HttpServletResponse response) { - return CompletableFuture.supplyAsync( - () -> { - final String notifyPing = this.sebClientConnectionService - .notifyPing(connectionToken, timestamp, pingNumber); - if (notifyPing == null) { - return EMPTY_PING_RESPONSE; - } + final String instruction = this.sebClientConnectionService + .notifyPing(connectionToken, timestamp, pingNumber); - return ResponseEntity - .ok() - .body(notifyPing); - }, - this.executor); + if (instruction == null) { + return; + } + + try { + response.getOutputStream().write(instruction.getBytes()); + } catch (final IOException e) { + log.error("Failed to send instruction as response: {}", connectionToken, e); + } } -// @RequestMapping( -// path = API.EXAM_API_PING_ENDPOINT, -// method = RequestMethod.POST, -// consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, -// produces = MediaType.APPLICATION_JSON_UTF8_VALUE) -// public ResponseEntity ping( -// @RequestHeader(name = API.EXAM_API_SEB_CONNECTION_TOKEN, required = true) final String connectionToken, -// @RequestParam(name = API.EXAM_API_PING_TIMESTAMP, required = true) final long timestamp, -// @RequestParam(name = API.EXAM_API_PING_NUMBER, required = false) final int pingNumber) { -// -// final String instruction = this.sebClientConnectionService -// .notifyPing(connectionToken, timestamp, pingNumber); -// -// if (instruction == null) { -// return EMPTY_PING_RESPONSE; -// } -// -// return ResponseEntity -// .ok() -// .body(instruction); -// } - @RequestMapping( path = API.EXAM_API_EVENT_ENDPOINT, method = RequestMethod.POST,