diff --git a/src/main/java/com/loafle/commons/server/websocket/client/Client.java b/src/main/java/com/loafle/commons/server/websocket/client/Client.java index 2b972dc..01ec0d5 100644 --- a/src/main/java/com/loafle/commons/server/websocket/client/Client.java +++ b/src/main/java/com/loafle/commons/server/websocket/client/Client.java @@ -1,6 +1,7 @@ package com.loafle.commons.server.websocket.client; import java.net.SocketAddress; +import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,7 +29,7 @@ import io.netty.handler.codec.http.websocketx.extensions.compression.WebSocketCl public class Client { private static final Logger logger = LoggerFactory.getLogger(Client.class); public static final String CHANNEL_CLASS = "CLIENT_CHANNEL_CLASS"; - public static final String CHANNEL_HANDLER = "CLIENT_CHANNEL_HANDLER"; + public static final String CHANNEL_HANDLERS = "CLIENT_CHANNEL_HANDLERS"; public static final String HANDSHAKER = "CLIENT_HANDSHAKER"; public static final String SOCKET_ADDRESS = "CLIENT_SOCKET_ADDRESS"; @@ -36,8 +37,8 @@ public class Client { @Qualifier(CHANNEL_CLASS) protected Class channelClass; @Autowired - @Qualifier(CHANNEL_HANDLER) - protected ChannelHandler handler; + @Qualifier(CHANNEL_HANDLERS) + protected List handlers; @Autowired @Qualifier(HANDSHAKER) WebSocketClientHandshaker handshaker; @@ -63,9 +64,13 @@ public class Client { new HttpClientCodec(), new HttpObjectAggregator(8192), WebSocketClientCompressionHandler.INSTANCE, - new WebSocketClientProtocolHandler(handshaker, true), - handler + new WebSocketClientProtocolHandler(handshaker, true) ); + if (null != handlers) { + for (ChannelHandler handler : handlers) { + p.addLast(handler); + } + } } });