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

org.fisco.bcos.channel.handler.Encoder Maven / Gradle / Ivy

There is a newer version: 2.6.6
Show newest version
package org.fisco.bcos.channel.handler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

public class Encoder extends MessageToByteEncoder {
	private static Logger logger = LoggerFactory.getLogger(Encoder.class);
	
	@Override
	protected void encode(ChannelHandlerContext ctx, Message msg, ByteBuf out) throws Exception {
		logger.debug("encode:" + msg.getLength() + "," + msg.getData());
		
		out.writeIntLE(msg.getLength());
		out.writeShortLE(msg.getType());
		out.writeBytes(msg.getData());
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy