12 Temmuz 2018 Perşembe

SpringWebSocket StompWebSocketEndpointRegistration Arayüzü

addInterceptors metodu
Elimizde şöyle bir kod olsun
public class WSHandshakeInterceptor implements HandshakeInterceptor {
  @Override
  public boolean beforeHandshake(ServerHttpRequest serverHttpRequest,
   ServerHttpResponse serverHttpResponse, WebSocketHandler webSocketHandler,
   Map<String, Object> map) throws Exception {
    return true;
  }


  @Override
  public void afterHandshake(ServerHttpRequest serverHttpRequest,
 ServerHttpResponse serverHttpResponse, WebSocketHandler webSocketHandler, Exception e) {
    ...
  }
}
Şöyle yaparız.
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
  registry.addEndpoint("/agent").addInterceptors(new WSHandshakeInterceptor())
    .withSockJS();
}

Hiç yorum yok:

Yorum Gönder