Package net.lightstone.net.codec

Source Code of net.lightstone.net.codec.RespawnCodec

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.RespawnMessage;

public final class RespawnCodec extends MessageCodec<RespawnMessage> {

  public RespawnCodec() {
    super(RespawnMessage.class, 0x09);
  }

  @Override
  public RespawnMessage decode(ChannelBuffer buffer) throws IOException {
    int dimension = buffer.readByte();
    return new RespawnMessage(dimension);
  }

  @Override
  public ChannelBuffer encode(RespawnMessage message) throws IOException {
    ChannelBuffer buffer = ChannelBuffers.buffer(1);
    buffer.writeByte(message.getDimension());
    return buffer;
  }

}
TOP

Related Classes of net.lightstone.net.codec.RespawnCodec

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.