@OnOpen
    public void onOpen(Session session, @PathParam("token") String token) throws IOException {
        SessionSet.add(session);
        this.session = session;
        int cnt = OnlineCount.incrementAndGet(); // Add 1 to the online number
        log.info("There are connections added, and the current number of connections is: {}", cnt);

        heartBeat(session);
        this.wsService = ApplicationContextUtil.getBean(WsService.class);
        Dbutils.setSession();
        this.loginUser = wsService.doLogin(token);
        if (this.loginUser == null) {
            ActionResult actionResult = new ActionResult();
            actionResult.setSuccess(false);
            actionResult.setErrorCode("LOGIN_FAIL");
            WsResult wsMessage = new WsResult();
            wsMessage.setActionType(WsMessage.ActionType.OPEN_SESSION);
            wsMessage.setUuid(token);
            wsMessage.setMessage(actionResult);
            SendMessage(this.session, wsMessage);
            onClose();
        }else {
            ActionResult actionResult = new ActionResult();
            actionResult.setSuccess(true);
            WsResult wsMessage = new WsResult();
            wsMessage.setActionType(WsMessage.ActionType.OPEN_SESSION);
            wsMessage.setUuid(token);
            wsMessage.setMessage(actionResult);
            SendMessage(this.session, wsMessage);
        }
        Dbutils.removeSession();
    }
Method called when connection is established successfully
chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/ws/WsServer.java