com.xzixi.websocket.interceptablewebsocket.interceptor.FromClientExecutionChain Maven / Gradle / Ivy
The newest version!
package com.xzixi.websocket.interceptablewebsocket.interceptor;
import com.xzixi.websocket.interceptablewebsocket.util.MessageFromClient;
import org.springframework.messaging.MessageChannel;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.messaging.StompSubProtocolHandler;
import java.security.Principal;
import java.util.List;
/**
* @see FromClientInterceptor
* @author 薛凌康
*/
public class FromClientExecutionChain {
private List interceptors;
private int interceptorIndex = -1;
public FromClientExecutionChain(List interceptors) {
Assert.notNull(interceptors, "interceptors不能为null");
this.interceptors = interceptors;
}
public boolean applyPreHandle(WebSocketSession session, Principal principal, MessageFromClient message, MessageChannel outputChannel, StompSubProtocolHandler handler) {
if (!ObjectUtils.isEmpty(interceptors)) {
for (int i=0; i= 0; i--) {
FromClientInterceptor interceptor = interceptors.get(i);
interceptor.postHandle(session, principal, message, outputChannel, handler);
}
}
}
}