io.nadron.client.handlers.netty.MessageBufferEventEncoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nadclient Show documentation
Show all versions of nadclient Show documentation
This is a client library for Nadron server https://github.com/menacher/java-game-server/tree/netty4/nadron. Java clients can use this program to connect and interact with nadron server.
package io.nadron.client.handlers.netty;
import io.nadron.client.communication.MessageBuffer;
import io.nadron.client.event.Event;
import io.nadron.client.event.Events;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageEncoder;
import java.util.List;
/**
* Converts an incoming {@link Event} which in turn has a
* IMessageBuffer payload to a Netty {@link ByteBuf}.
* Note that {@link Event} instances containing other type of objects as its
* payload will result in {@link ClassCastException}.
*
* @author Abraham Menacherry.
*
*/
// TODO check if MessageToMessageEncoder can be replaced with MessageToByteEncoder
@Sharable
public class MessageBufferEventEncoder extends MessageToMessageEncoder
{
@Override
protected void encode(ChannelHandlerContext ctx, Event event,
List