Finished reading from stream

This commit is contained in:
Marcin Kostrzewski 2020-10-29 11:40:18 +01:00
parent cc3ddcdd4f
commit 70331f6f3c

View File

@ -114,6 +114,17 @@ public class ProtocolMessage {
totalBytesRead += bytesRead;
}
int messageLength = charArrayToInt(this.raw);
while(totalBytesRead != 4 + messageLength){
int bytesRead = reader.read(this.raw, totalBytesRead, messageLength - totalBytesRead);
if (bytesRead == -1) {
logger.log(Level.ERROR, "Invalid packet.");
return;
} else
totalBytesRead += bytesRead;
}
deconstructPacket(this.raw);
}