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 ab8cd316..e0d0d0a6 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 @@ -274,53 +274,53 @@ public class ExamAPI_V1_Controller { .ok() .build(); -// @RequestMapping( -// path = API.EXAM_API_PING_ENDPOINT, -// method = RequestMethod.POST, -// consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, -// produces = MediaType.APPLICATION_JSON_UTF8_VALUE) -// public CompletableFuture> 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) { -// -// return CompletableFuture.supplyAsync( -// () -> { -// final String notifyPing = this.sebClientConnectionService -// .notifyPing(connectionToken, timestamp, pingNumber); -// if (notifyPing == null) { -// return EMPTY_PING_RESPONSE; -// } -// -// return ResponseEntity -// .ok() -// .body(notifyPing); -// }, -// this.executor); -// } - @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( + public CompletableFuture> 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); + return CompletableFuture.supplyAsync( + () -> { + final String notifyPing = this.sebClientConnectionService + .notifyPing(connectionToken, timestamp, pingNumber); + if (notifyPing == null) { + return EMPTY_PING_RESPONSE; + } - if (instruction == null) { - return EMPTY_PING_RESPONSE; - } - - return ResponseEntity - .ok() - .body(instruction); + return ResponseEntity + .ok() + .body(notifyPing); + }, + this.executor); } +// @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,