Joburgess преди 4 години
родител
ревизия
d3b74cf71b
променени са 1 файла, в които са добавени 12 реда и са изтрити 0 реда
  1. 12 0
      mec-teacher/src/main/java/com/ym/mec/teacher/controller/SoundController.java

+ 12 - 0
mec-teacher/src/main/java/com/ym/mec/teacher/controller/SoundController.java

@@ -68,4 +68,16 @@ public class SoundController extends BaseController {
         return succeed();
     }
 
+    @RequestMapping("closeWebSocket")
+    public HttpResponseResult closeWebSocket(String phone) throws IOException {
+        if(!WebSocketHandler.WS_CLIENTS.containsKey(phone)){
+            return failed("未上线");
+        }
+        if(!WebSocketHandler.WS_CLIENTS.get(phone).isOpen()){
+            return failed("已离线");
+        }
+        WebSocketHandler.WS_CLIENTS.get(phone).close();
+        return succeed();
+    }
+
 }