Package net.lightstone.net.codec

Source Code of net.lightstone.net.codec.CollectItemCodec

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

public final class CollectItemCodec extends MessageCodec<CollectItemMessage> {

  public CollectItemCodec() {
    super(CollectItemMessage.class, 0x16);
  }

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

  @Override
  public ChannelBuffer encode(CollectItemMessage message) throws IOException {
    ChannelBuffer buffer = ChannelBuffers.buffer(8);
    buffer.writeInt(message.getId());
    buffer.writeInt(message.getCollector());
    return buffer;
  }

}
TOP

Related Classes of net.lightstone.net.codec.CollectItemCodec

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.