Package net.lightstone.net.codec

Source Code of net.lightstone.net.codec.AnimateEntityCodec

package net.lightstone.net.codec;

import java.io.IOException;

import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;

import net.lightstone.msg.AnimateEntityMessage;

public final class AnimateEntityCodec extends MessageCodec<AnimateEntityMessage> {

  public AnimateEntityCodec() {
    super(AnimateEntityMessage.class, 0x12);
  }

  @Override
  public AnimateEntityMessage decode(ChannelBuffer buffer) throws IOException {
    int id = buffer.readInt();
    int animation = buffer.readUnsignedByte();
    return new AnimateEntityMessage(id, animation);
  }

  @Override
  public ChannelBuffer encode(AnimateEntityMessage message) throws IOException {
    ChannelBuffer buffer = ChannelBuffers.buffer(5);
    buffer.writeInt(message.getId());
    buffer.writeByte(message.getAnimation());
    return buffer;
  }

}
TOP

Related Classes of net.lightstone.net.codec.AnimateEntityCodec

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.