use of com.ngtesting.platform.bean.ApplicationScopeBean in project ngtesting-platform by aaronchen2k.
the class WebSocketHandshakeInterceptor method beforeHandshake.
@Override
public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Map<String, Object> attributes) throws Exception {
ApplicationScopeBean scopeBean = SpringContextHolder.getBean(ApplicationScopeBean.class);
if (request instanceof ServletServerHttpRequest) {
ServletServerHttpRequest servletRequest = (ServletServerHttpRequest) request;
HttpSession httpSession = servletRequest.getServletRequest().getSession(true);
String test = (String) httpSession.getAttribute("TEST");
UserVo user = null;
if (httpSession.getAttribute(Constant.HTTP_SESSION_USER_KEY) != null) {
user = (UserVo) httpSession.getAttribute(Constant.HTTP_SESSION_USER_KEY);
}
if (user != null) {
attributes.put(WsConstant.WS_USER_KEY, user.getId().toString());
attributes.put("somthing", "somthing");
return true;
}
}
return false;
}
Aggregations