This commit is contained in:
Administrator
2025-04-24 10:16:38 +08:00
parent 6de65562be
commit 7267aec1fd
108 changed files with 7621 additions and 1890 deletions
@@ -34,7 +34,7 @@ public abstract class KLALBRoutingProtocolPacket extends NetworkPacket {
public KLALBRoutingProtocolPacket(int type) {
super();
header=NetworkPacket.databufferpool_40.borrow();
header=NetworkPacket.bufferAllocator.allocate(40);
header.put((byte) type);
}
@Override
@@ -49,7 +49,7 @@ public abstract class KLALBRoutingProtocolPacket extends NetworkPacket {
protected void writeToChannel(WritableByteChannel dto) throws IOException {
public void writeToChannel(WritableByteChannel dto) throws IOException {
sndtime=System.nanoTime();
dto.write(header.slice(0, (int) getHeaderSize()));
}
@@ -59,7 +59,7 @@ public abstract class KLALBRoutingProtocolPacket extends NetworkPacket {
return false;
}
protected void readFromChannel(ReadableByteChannel din,long length) throws IOException {
public void readFromChannel(ReadableByteChannel din,long length) throws IOException {
rcvtime=System.nanoTime();
//System.out.println(this+" "+getHeaderSize());
header.limit((int) getHeaderSize());
@@ -89,12 +89,6 @@ public abstract class KLALBRoutingProtocolPacket extends NetworkPacket {
return header;
}
public void dispose() {
super.dispose();
/* ByteBuffer headerx=header;
header=null;
KLALBRoutingProtocolPacket.databufferpool_40.back(headerx);*/
}
public static KLALBRoutingProtocolPacket readKLALBPacketFromStream(DataInputStream in) throws IOException {
return readKLALBPacketFromChannel(Channels.newChannel(in));
@@ -102,7 +96,7 @@ public abstract class KLALBRoutingProtocolPacket extends NetworkPacket {
public static KLALBRoutingProtocolPacket readKLALBPacketFromChannel(ReadableByteChannel in) throws IOException {
while(true) {
ByteBuffer bb=databufferpool_40.borrow();
ByteBuffer bb=NetworkPacket.bufferAllocator.allocate(40);
bb.limit(1);
while(bb.hasRemaining()){
if(in.read(bb)==-1) {