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
2 changed files with 2 additions and 2 deletions
@@ -39,7 +39,7 @@ public enum ConstructingDeserializer implements MessageDeserializer {
} }
@Override @Override
public iMessage deserialize(DataInputStream in) throws IOException { public synchronized iMessage deserialize(DataInputStream in) throws IOException {
int type = ((int) in.readByte()) & 0xff; int type = ((int) in.readByte()) & 0xff;
try { try {
return MSGS.get(type).getConstructor(DataInputStream.class).newInstance(in); return MSGS.get(type).getConstructor(DataInputStream.class).newInstance(in);
@@ -35,7 +35,7 @@ public class SerializedConnection implements IConnection {
} }
@Override @Override
public void sendMessage(iMessage message) throws IOException { public synchronized void sendMessage(iMessage message) throws IOException {
message.writeHeader(out); message.writeHeader(out);
message.write(out); message.write(out);
} }