Package net.lightstone.net.codec

Source Code of net.lightstone.net.codec.HealthCodec

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

public final class HealthCodec extends MessageCodec<HealthMessage> {

  public HealthCodec() {
    super(HealthMessage.class, 0x08);
  }

  @Override
  public HealthMessage decode(ChannelBuffer buffer) throws IOException {
    int health = buffer.readUnsignedByte();
    return new HealthMessage(health);
  }

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

}
TOP

Related Classes of net.lightstone.net.codec.HealthCodec

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.