All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tydic.mysql.async.MySQLBufferFrameDecoder Maven / Gradle / Ivy

There is a newer version: 1.7
Show newest version
package com.tydic.mysql.async;

import io.netty.buffer.ByteBuf;
import io.netty.handler.codec.DecoderException;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;

import java.nio.ByteOrder;

/**
 * Created by shihailong on 2017/9/21.
 */
public class MySQLBufferFrameDecoder extends LengthFieldBasedFrameDecoder {

    public MySQLBufferFrameDecoder() {
        super(Integer.MAX_VALUE, 0, 3, 1, 0);
    }

    @Override
    protected long getUnadjustedFrameLength(ByteBuf buf, int offset, int length, ByteOrder order) {
        if (length == 3) {
            return buf.getUnsignedMediumLE(offset);
        } else {
            throw new DecoderException(
                    "unsupported lengthFieldLength: " + length + " (expected: 3)");
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy