Fix race condition

This commit is contained in:
Flare Microsystems
2024-11-16 21:13:52 -08:00
parent 7eb283592e
commit 32203cde49

View File

@@ -6,20 +6,21 @@ import java.io.IOException;
import com.flaremicro.crossjeeves.net.NetworkHandler;
public class Packet4FileData extends Packet{
public class Packet4FileData extends Packet {
private long fileId;
private short chunkSize;
private byte[] fileChunk;
public Packet4FileData(){
public Packet4FileData() {
}
public Packet4FileData(long fileId, short chunkSize, byte[] fileChunk){
public Packet4FileData(long fileId, short chunkSize, byte[] fileChunk) {
this.fileId = fileId;
this.chunkSize = chunkSize;
this.fileChunk = fileChunk;
this.fileChunk = new byte[chunkSize];
System.arraycopy(fileChunk, 0, this.fileChunk, 0, chunkSize);
}
public void recievePacket(DataInputStream in) throws IOException {
fileId = in.readLong();
chunkSize = in.readShort();
@@ -33,25 +34,22 @@ public class Packet4FileData extends Packet{
out.writeShort(chunkSize);
out.write(fileChunk, 0, chunkSize);
}
public void processPacket(NetworkHandler networkHandler){
public void processPacket(NetworkHandler networkHandler) {
networkHandler.handlePacket(this);
}
public long getFileId()
{
public long getFileId() {
return fileId;
}
public byte[] getFileChunk()
{
public byte[] getFileChunk() {
return fileChunk;
}
@Override
public Packet cloneTypeOnly() {
return new Packet4FileData();
}
}