com.gateway.connector.tcp.codec.WebSocketProtoCodec Maven / Gradle / Ivy
package com.gateway.connector.tcp.codec;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.gateway.connector.proto.Proto;
import com.gateway.utils.ProtoUtils;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageCodec;
import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame;
import io.netty.handler.codec.http.websocketx.WebSocketFrame;
/**
* WebSocket
*/
@Component
@ChannelHandler.Sharable
public class WebSocketProtoCodec extends MessageToMessageCodec {
public static final int INT_SIZE = Integer.BYTES;
private Logger logger = LoggerFactory.getLogger(WebSocketProtoCodec.class);
private boolean isGzip=false;
public WebSocketProtoCodec(boolean isGzip) {
this.isGzip=isGzip;
}
@Override
protected void encode(ChannelHandlerContext ctx, Proto proto, List