// Path: src/main/java/com/cf/client/wss/handler/LoggingMessageHandler.java
// public class LoggingMessageHandler implements IMessageHandler {
// 
//     private final static Logger LOG = LogManager.getLogger();
// 
//     @Override
//     public void handle(String message) {
//         LOG.info(message);
//     }
// 
// }
// 
// Path: src/main/java/com/cf/client/wss/handler/IMessageHandler.java
// public interface IMessageHandler {
//     public void handle(String message);
// }


import com.cf.client.wss.handler.LoggingMessageHandler;
import com.google.gson.Gson;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.codec.http.DefaultHttpHeaders;
import io.netty.handler.codec.http.FullHttpResponse;
import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker;
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory;
import io.netty.handler.codec.http.websocketx.WebSocketFrame;
import io.netty.handler.codec.http.websocketx.WebSocketHandshakeException;
import io.netty.handler.codec.http.websocketx.WebSocketVersion;
import io.netty.util.CharsetUtil;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Map;
import com.cf.client.wss.handler.IMessageHandler;
package com.cf.client.poloniex;



public class PoloniexWSSClientRouter extends SimpleChannelInboundHandler<Object> {

    private final static Logger LOG = LogManager.getLogger();
    private static final int MAX_FRAME_LENGTH = 1262144;

    private final WebSocketClientHandshaker handshaker;
    private ChannelPromise handshakeFuture;    
    private boolean running;
    
    private Map<Double, IMessageHandler> subscriptions;
    private final IMessageHandler defaultSubscriptionMessageHandler;
    private final Gson gson;

    public PoloniexWSSClientRouter(URI url, Map<Double, IMessageHandler> subscriptions) throws URISyntaxException {
        this(WebSocketClientHandshakerFactory
                .newHandshaker(url, WebSocketVersion.V13, null, true, new DefaultHttpHeaders(), MAX_FRAME_LENGTH), subscriptions);
    }

    public PoloniexWSSClientRouter(WebSocketClientHandshaker handshaker, Map<Double, IMessageHandler> subscriptions) {
        this.handshaker = handshaker;
        this.subscriptions = subscriptions;
// Path: src/main/java/com/cf/client/wss/handler/LoggingMessageHandler.java
// public class LoggingMessageHandler implements IMessageHandler {
// 
//     private final static Logger LOG = LogManager.getLogger();
// 
//     @Override
//     public void handle(String message) {
//         LOG.info(message);
//     }
// 
// }
// 
// Path: src/main/java/com/cf/client/wss/handler/IMessageHandler.java
// public interface IMessageHandler {
//     public void handle(String message);
// }


// Path: src/main/java/com/cf/client/poloniex/PoloniexWSSClientRouter.java
import com.cf.client.wss.handler.LoggingMessageHandler;
import com.google.gson.Gson;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.codec.http.DefaultHttpHeaders;
import io.netty.handler.codec.http.FullHttpResponse;
import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker;
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory;
import io.netty.handler.codec.http.websocketx.WebSocketFrame;
import io.netty.handler.codec.http.websocketx.WebSocketHandshakeException;
import io.netty.handler.codec.http.websocketx.WebSocketVersion;
import io.netty.util.CharsetUtil;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Map;
import com.cf.client.wss.handler.IMessageHandler;

package com.cf.client.poloniex;



public class PoloniexWSSClientRouter extends SimpleChannelInboundHandler<Object> {

    private final static Logger LOG = LogManager.getLogger();
    private static final int MAX_FRAME_LENGTH = 1262144;

    private final WebSocketClientHandshaker handshaker;
    private ChannelPromise handshakeFuture;    
    private boolean running;
    
    private Map<Double, IMessageHandler> subscriptions;
    private final IMessageHandler defaultSubscriptionMessageHandler;
    private final Gson gson;

    public PoloniexWSSClientRouter(URI url, Map<Double, IMessageHandler> subscriptions) throws URISyntaxException {
        this(WebSocketClientHandshakerFactory
                .newHandshaker(url, WebSocketVersion.V13, null, true, new DefaultHttpHeaders(), MAX_FRAME_LENGTH), subscriptions);
    }

    public PoloniexWSSClientRouter(WebSocketClientHandshaker handshaker, Map<Double, IMessageHandler> subscriptions) {
        this.handshaker = handshaker;
        this.subscriptions = subscriptions;
        this.defaultSubscriptionMessageHandler = new LoggingMessageHandler();