![JAR search and dependency download from the Maven repository](/logo.png)
cocaine.netty.MessageEncoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cocaine-client Show documentation
Show all versions of cocaine-client Show documentation
Client for Cocaine Application Engine.
The newest version!
package cocaine.netty;
import cocaine.message.Message;
import cocaine.msgpack.MessageTemplate;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import org.apache.log4j.Logger;
import org.msgpack.MessagePack;
/**
* @author Anton Bobukh
*/
public class MessageEncoder extends MessageToByteEncoder {
private static final Logger logger = Logger.getLogger(MessageEncoder.class);
private final MessagePack pack;
public MessageEncoder(MessagePack pack) {
super(Message.class);
this.pack = pack;
}
@Override
protected void encode(ChannelHandlerContext ctx, Message msg, ByteBuf out) throws Exception {
logger.debug("Encoding message: " + msg);
out.writeBytes(pack.write(msg, MessageTemplate.getInstance()));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy