whyclxw
2025-05-15 96510a549bfb313920bf297b28089c4cf57f0146
src/main/java/com/whyc/webSocket/HomeSocket.java
@@ -44,22 +44,19 @@
    @OnOpen
    public void onOpen(Session session, EndpointConfig config) {
        this.session = session;
        /*HttpSession httpSession = (HttpSession) config.getUserProperties().get("httpSession");
        HttpSession httpSession = (HttpSession) config.getUserProperties().get("httpSession");
        UserInf user = (UserInf) httpSession.getAttribute("user");
        final int userId = user.getUid();*/
        final int userId = 10001;
        final int userId = user.getUid();
        //final int userId = 10001;
        Thread thread = new Thread("Thread_HomeSocket") {
            @Override
            public void run() {
                try {
                    while (!currentThread().isInterrupted()) {
                        while (!currentThread().isInterrupted()) {
                            Map<String, Object> res = sendHome(userId);
                            session.getBasicRemote().sendObject(new Response().set(1, res));
                            sleep(5000);
                        }
                        Map<String, Object> res = sendHome(userId);
                        session.getBasicRemote().sendObject(new Response().set(1, res));
                        sleep(5000);
                    }
                } catch (Exception e) {
                    this.interrupt();