org.springframework.web.socket.server
Interface HandshakeInterceptor
所有已知實(shí)現(xiàn)類(lèi)
HttpSessionHandshakeInterceptor
public interface HandshakeInterceptor
WebSocket握手請(qǐng)求的攔截器. 檢查握手請(qǐng)求和響應(yīng), 對(duì)WebSocketHandler傳遞屬性
-
boolean beforeHandShake(ServerHttpRequest request,ServerHttpResponse response, WebSocketHandler wsHandler, Map<String, Object> attributes) throws Exception
在握手之前執(zhí)行該方法, 繼續(xù)握手返回true, 中斷握手返回false. 通過(guò)attributes參數(shù)設(shè)置WebSocketSession的屬性 -
void afterHandshake(ServerHttpRequest request,ServerHttpResponse response, WebSocketHandler wsHandler, Map<String, Object> attributes) throws Exception
在握手之后執(zhí)行該方法. 無(wú)論是否握手成功都指明了響應(yīng)狀態(tài)碼和相應(yīng)頭.
參考資料: spring技術(shù)文檔