Improved snapshot netcode

This commit is contained in:
Anuken
2018-12-29 22:46:46 -05:00
parent 7c35b6e95a
commit d01b8c7ad1
17 changed files with 99 additions and 216 deletions

View File

@@ -20,6 +20,8 @@ import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.nio.BufferOverflowException;
import java.nio.BufferUnderflowException;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedSelectorException;
@@ -157,10 +159,15 @@ public class KryoClient implements ClientProvider{
@Override
public void send(Object object, SendMode mode){
if(mode == SendMode.tcp){
client.sendTCP(object);
}else{
client.sendUDP(object);
try{
if(mode == SendMode.tcp){
client.sendTCP(object);
}else{
client.sendUDP(object);
}
//sending things can cause an under/overflow, catch it and disconnect instead of crashing
}catch(BufferOverflowException | BufferUnderflowException e){
Net.showError(e);
}
Pools.free(object);