io.nadron.handlers.netty.MessageBufferEventDecoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nadron Show documentation
Show all versions of nadron Show documentation
Nadron is a high speed socket based java game server written using Netty and Mike Rettig's Jetlang. It is specifically tuned for network based multiplayer games and supports TCP and UDP network protocols.
package io.nadron.handlers.netty;
import io.nadron.communication.NettyMessageBuffer;
import io.nadron.event.Event;
import io.nadron.event.Events;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
import java.util.List;
/**
* This decoder will convert a Netty {@link ByteBuf} to a
* {@link NettyMessageBuffer}. It will also convert
* {@link Events#NETWORK_MESSAGE} events to {@link Events#SESSION_MESSAGE}
* event.
*
* @author Abraham Menacherry
*
*/
//TODO check if MessageToMessageDecoder can be replaced with MessageToByteDecoder
@Sharable
public class MessageBufferEventDecoder extends MessageToMessageDecoder
{
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf buffer,
List