mirror of
https://github.com/Minestom/Minestom.git
synced 2025-04-16 17:16:11 +02:00
Added KQueue support on OSX + netty version update
This commit is contained in:
parent
1bf8c5f89b
commit
2d009e19a7
@ -101,9 +101,10 @@ dependencies {
|
||||
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.6.2')
|
||||
|
||||
// Netty
|
||||
api 'io.netty:netty-handler:4.1.52.Final'
|
||||
api 'io.netty:netty-codec:4.1.52.Final'
|
||||
implementation 'io.netty:netty-transport-native-epoll:4.1.52.Final:linux-x86_64'
|
||||
api 'io.netty:netty-handler:4.1.54.Final'
|
||||
api 'io.netty:netty-codec:4.1.54.Final'
|
||||
api 'io.netty:netty-transport-native-epoll:4.1.54.Final:linux-x86_64'
|
||||
api 'io.netty:netty-transport-native-kqueue:4.1.54.Final:osx-x86_64'
|
||||
|
||||
// https://mvnrepository.com/artifact/it.unimi.dsi/fastutil
|
||||
api 'it.unimi.dsi:fastutil:8.4.2'
|
||||
|
@ -173,6 +173,10 @@ public final class ConnectionManager {
|
||||
|
||||
/**
|
||||
* Adds a consumer to call once a packet is sent.
|
||||
* <p>
|
||||
* Be aware that it is possible for the same packet instance to be used multiple time,
|
||||
* changing the object fields could lead to issues.
|
||||
* (consider canceling the packet instead and send your own)
|
||||
*
|
||||
* @param packetConsumer the packet consumer
|
||||
*/
|
||||
|
@ -5,6 +5,9 @@ import io.netty.channel.*;
|
||||
import io.netty.channel.epoll.Epoll;
|
||||
import io.netty.channel.epoll.EpollEventLoopGroup;
|
||||
import io.netty.channel.epoll.EpollServerSocketChannel;
|
||||
import io.netty.channel.kqueue.KQueue;
|
||||
import io.netty.channel.kqueue.KQueueEventLoopGroup;
|
||||
import io.netty.channel.kqueue.KQueueServerSocketChannel;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.socket.ServerSocketChannel;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
@ -34,12 +37,17 @@ public class NettyServer {
|
||||
|
||||
if (Epoll.isAvailable()) {
|
||||
boss = new EpollEventLoopGroup(2);
|
||||
worker = new EpollEventLoopGroup();
|
||||
worker = new EpollEventLoopGroup(); // thread count = core * 2
|
||||
|
||||
channel = EpollServerSocketChannel.class;
|
||||
} else if (KQueue.isAvailable()) {
|
||||
boss = new KQueueEventLoopGroup(2);
|
||||
worker = new KQueueEventLoopGroup(); // thread count = core * 2
|
||||
|
||||
channel = KQueueServerSocketChannel.class;
|
||||
} else {
|
||||
boss = new NioEventLoopGroup(2);
|
||||
worker = new NioEventLoopGroup();
|
||||
worker = new NioEventLoopGroup(); // thread count = core * 2
|
||||
|
||||
channel = NioServerSocketChannel.class;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.chat.ChatColor;
|
||||
import net.minestom.server.chat.ColoredText;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.listener.manager.PacketConsumer;
|
||||
import net.minestom.server.listener.manager.PacketListenerManager;
|
||||
import net.minestom.server.network.ConnectionManager;
|
||||
import net.minestom.server.network.ConnectionState;
|
||||
@ -75,10 +76,10 @@ public abstract class PlayerConnection {
|
||||
/**
|
||||
* Serializes the packet and send it to the client.
|
||||
* <p>
|
||||
* Also responsible for executing {@link ConnectionManager#getSendPacketConsumers()} consumers.
|
||||
* Also responsible for executing {@link ConnectionManager#onPacketSend(PacketConsumer)} consumers.
|
||||
*
|
||||
* @param serverPacket the packet to send
|
||||
* @see #shouldSendPacket(ServerPacket)
|
||||
* @see #shouldSendPacket(ServerPacket)
|
||||
*/
|
||||
public abstract void sendPacket(@NotNull ServerPacket serverPacket);
|
||||
|
||||
|
@ -85,7 +85,7 @@ public class PlayerInit {
|
||||
|
||||
connectionManager.onPacketSend((player, packetController, packet) -> {
|
||||
// Listen to all sent packet
|
||||
System.out.println("PACKET: " + packet.getClass().getSimpleName());
|
||||
// System.out.println("PACKET: " + packet.getClass().getSimpleName());
|
||||
packetController.setCancel(false);
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user