how to get id of current user in websocket open method?
问题 I am trying to get user id in open method of websocket, and for this I am using shiro, but I get null for Subject,Here is my method: @OnOpen public void open(final Session session, @PathParam("room") final String room) { Subject currentUser = SecurityUtils.getSubject(); long id = currentUser.getPrincipals().oneByType(model.Users.class) .getId(); log.info("session openend and bound to room: " + room); session.getUserProperties().put("user", id); } Does anybody have any idea what I should do?