package org.kne.cloud.network;

import java.io.IOException;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.WritableByteChannel;

public abstract class NetworkPacket{
	
	public static final ByteBufferAllocator bufferAllocator=new ByteBufferAllocator(true);
	
	
	public abstract long getTotalLength();
	

	
	public abstract void writeToChannel(WritableByteChannel dto) throws IOException ;
	public abstract void readFromChannel(ReadableByteChannel din,long length) throws IOException;
	public void readFromChannel(ReadableByteChannel din) throws IOException{
		readFromChannel(din,-1);
	}
	protected abstract boolean needEndPosition();
}
