mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-08 00:11:34 +01:00
Fix by checking if the connection uses inet socket (#1152)
This commit is contained in:
parent
2289cf32e1
commit
b112248ae8
@ -107,6 +107,7 @@ public class Main {
|
||||
OpenToLAN.open(new OpenToLANConfig().eventCallDelay(Duration.of(1, TimeUnit.DAY)));
|
||||
|
||||
minecraftServer.start("0.0.0.0", 25565);
|
||||
// minecraftServer.start(java.net.UnixDomainSocketAddress.of("minestom-demo.sock"));
|
||||
//Runtime.getRuntime().addShutdownHook(new Thread(MinecraftServer::stopCleanly));
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import org.jctools.queues.MpscUnboundedXaddArrayQueue;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.Selector;
|
||||
@ -109,11 +110,13 @@ public final class Worker extends MinestomThread {
|
||||
this.connectionMap.put(channel, new PlayerSocketConnection(this, channel, channel.getRemoteAddress()));
|
||||
channel.configureBlocking(false);
|
||||
channel.register(selector, SelectionKey.OP_READ);
|
||||
if (channel.getLocalAddress() instanceof InetSocketAddress) {
|
||||
Socket socket = channel.socket();
|
||||
socket.setSendBufferSize(Server.SOCKET_SEND_BUFFER_SIZE);
|
||||
socket.setReceiveBufferSize(Server.SOCKET_RECEIVE_BUFFER_SIZE);
|
||||
socket.setTcpNoDelay(Server.NO_DELAY);
|
||||
socket.setSoTimeout(30 * 1000); // 30 seconds
|
||||
}
|
||||
this.selector.wakeup();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user