Merge branch 'comms' into tenor

This commit is contained in:
Leijurv 2018-11-23 16:35:35 -08:00
commit 82c64d4d06
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
2 changed files with 5 additions and 3 deletions

View File

@ -84,6 +84,10 @@ public class BufferedConnection implements IConnection {
return msgs;
}
public void handleAllPendingMessages(IMessageListener listener) throws IOException {
receiveMessagesNonBlocking().forEach(msg -> msg.handle(listener));
}
public static BufferedConnection makeBuffered(IConnection conn) {
if (conn instanceof BufferedConnection) {
return (BufferedConnection) conn;

View File

@ -38,7 +38,6 @@ import cabaletta.comms.upward.MessageStatus;
import net.minecraft.util.math.BlockPos;
import java.io.IOException;
import java.util.List;
import java.util.Objects;
public class ControllerBehavior extends Behavior implements IMessageListener {
@ -91,8 +90,7 @@ public class ControllerBehavior extends Behavior implements IMessageListener {
return;
}
try {
List<iMessage> msgs = conn.receiveMessagesNonBlocking();
msgs.forEach(msg -> msg.handle(this));
conn.handleAllPendingMessages(this);
} catch (IOException e) {
e.printStackTrace();
disconnect();