123
This commit is contained in:
@@ -18,6 +18,10 @@ public class WebSocketSessionHolder {
|
|||||||
|
|
||||||
private static final Map<String, WebSocketSession> USER_SESSION_MAP = new ConcurrentHashMap<>();
|
private static final Map<String, WebSocketSession> USER_SESSION_MAP = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public static int size(){
|
||||||
|
return USER_SESSION_MAP.size();
|
||||||
|
}
|
||||||
|
|
||||||
public static void addSession(String sessionKey, WebSocketSession session) {
|
public static void addSession(String sessionKey, WebSocketSession session) {
|
||||||
USER_SESSION_MAP.put(sessionKey, session);
|
USER_SESSION_MAP.put(sessionKey, session);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.ruoyi.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class IndexController {
|
||||||
|
@GetMapping("/ok")
|
||||||
|
public String ok(){
|
||||||
|
return "ok";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.ruoyi.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.ruoyi.cai.ws.holder.WebSocketSessionHolder;
|
||||||
|
import com.ruoyi.cai.ws.util.WebSocketUtils;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/cai/test")
|
||||||
|
public class TestController {
|
||||||
|
public R getSession(){
|
||||||
|
int size = WebSocketSessionHolder.size();
|
||||||
|
return R.ok(size);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user