package cn.socket.socket;

import javax.servlet.http.HttpSession;
import javax.websocket.HandshakeResponse;
import javax.websocket.server.HandshakeRequest;
import javax.websocket.server.ServerEndpointConfig;

/**
 * Description	获取WebSocket Open时当前用户HttpSession
 */
public class HttpChatSessionConfigurator extends ServerEndpointConfig.Configurator {

	@Override
	public void modifyHandshake(ServerEndpointConfig config, HandshakeRequest request, HandshakeResponse response) {
		HttpSession httpSession = (HttpSession) request.getHttpSession();
		if (null != httpSession) {
			config.getUserProperties().put(HttpSession.class.getName(), httpSession);
		}
	}
}
