synchronize partial reads and writes to a socket

This commit is contained in:
Leijurv 2018-11-23 10:09:13 -08:00
parent 0dc67593bb
commit 81ecc209d3
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
2 changed files with 2 additions and 2 deletions

View File

@ -39,7 +39,7 @@ public enum ConstructingDeserializer implements MessageDeserializer {
}
@Override
public iMessage deserialize(DataInputStream in) throws IOException {
public synchronized iMessage deserialize(DataInputStream in) throws IOException {
int type = ((int) in.readByte()) & 0xff;
try {
return MSGS.get(type).getConstructor(DataInputStream.class).newInstance(in);

View File

@ -35,7 +35,7 @@ public class SerializedConnection implements IConnection {
}
@Override
public void sendMessage(iMessage message) throws IOException {
public synchronized void sendMessage(iMessage message) throws IOException {
message.writeHeader(out);
message.write(out);
}