aboutsummaryrefslogtreecommitdiff
path: root/juick-ws/src/main/java/com/juick/ws/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'juick-ws/src/main/java/com/juick/ws/controllers')
-rw-r--r--juick-ws/src/main/java/com/juick/ws/controllers/ApiController.java25
-rw-r--r--juick-ws/src/main/java/com/juick/ws/controllers/StatusController.java32
2 files changed, 57 insertions, 0 deletions
diff --git a/juick-ws/src/main/java/com/juick/ws/controllers/ApiController.java b/juick-ws/src/main/java/com/juick/ws/controllers/ApiController.java
new file mode 100644
index 00000000..2f57b0b6
--- /dev/null
+++ b/juick-ws/src/main/java/com/juick/ws/controllers/ApiController.java
@@ -0,0 +1,25 @@
+package com.juick.ws.controllers;
+
+import com.juick.server.helpers.Status;
+import com.juick.ws.WebsocketComponent;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.inject.Inject;
+
+/**
+ * Created by vitalyster on 25.07.2016.
+ */
+@RestController
+public class ApiController {
+ @Inject
+ WebsocketComponent wsHandler;
+
+ @RequestMapping(value = "/api/status", method = RequestMethod.GET,
+ produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Status status() {
+ return new Status(String.valueOf(wsHandler.getClients().size()));
+ }
+}
diff --git a/juick-ws/src/main/java/com/juick/ws/controllers/StatusController.java b/juick-ws/src/main/java/com/juick/ws/controllers/StatusController.java
new file mode 100644
index 00000000..2fe55eeb
--- /dev/null
+++ b/juick-ws/src/main/java/com/juick/ws/controllers/StatusController.java
@@ -0,0 +1,32 @@
+package com.juick.ws.controllers;
+
+import com.juick.ws.WebsocketComponent;
+import com.juick.ws.XMPPConnection;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.inject.Inject;
+
+/**
+ * Created by vitalyster on 19.07.2016.
+ */
+@Controller
+@ResponseBody
+public class StatusController {
+ @Inject
+ WebsocketComponent wsHandler;
+ @Inject
+ XMPPConnection ws;
+
+ @RequestMapping(method = RequestMethod.GET, headers = "Connection!=upgrade", value = "/")
+ public ModelAndView status() {
+ ModelAndView modelAndView = new ModelAndView();
+ modelAndView.addObject("clients", wsHandler.getClients().size());
+ modelAndView.setViewName("index");
+ return modelAndView;
+ }
+
+}