Skip to content

Commit

Permalink
Allow accessing backing class for a channel instead of only its facto…
Browse files Browse the repository at this point in the history
…ry (#859)

Some netty libraries that are poorly coded only accept classes. Example: CloudburstMC/Network#42
  • Loading branch information
AlexProgrammerDE authored Sep 17, 2024
1 parent 4148fa9 commit de6bbe5
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ public enum TransportMethod {
}

public record TransportType(TransportMethod method,
Class<? extends ServerSocketChannel> serverSocketChannelClass,
ChannelFactory<? extends ServerSocketChannel> serverSocketChannelFactory,
Class<? extends SocketChannel> socketChannelClass,
ChannelFactory<? extends SocketChannel> socketChannelFactory,
Class<? extends DatagramChannel> datagramChannelClass,
ChannelFactory<? extends DatagramChannel> datagramChannelFactory,
Function<ThreadFactory, EventLoopGroup> eventLoopGroupFactory,
boolean supportsTcpFastOpenServer,
Expand All @@ -46,8 +49,11 @@ public static TransportType determineTransportMethod() {
if (isClassAvailable("io.netty.incubator.channel.uring.IOUring") && IOUring.isAvailable()) {
return new TransportType(
TransportMethod.IO_URING,
IOUringServerSocketChannel.class,
IOUringServerSocketChannel::new,
IOUringSocketChannel.class,
IOUringSocketChannel::new,
IOUringDatagramChannel.class,
IOUringDatagramChannel::new,
factory -> new IOUringEventLoopGroup(0, factory),
IOUring.isTcpFastOpenServerSideAvailable(),
Expand All @@ -58,8 +64,11 @@ public static TransportType determineTransportMethod() {
if (isClassAvailable("io.netty.channel.epoll.Epoll") && Epoll.isAvailable()) {
return new TransportType(
TransportMethod.EPOLL,
EpollServerSocketChannel.class,
EpollServerSocketChannel::new,
EpollSocketChannel.class,
EpollSocketChannel::new,
EpollDatagramChannel.class,
EpollDatagramChannel::new,
factory -> new EpollEventLoopGroup(0, factory),
Epoll.isTcpFastOpenServerSideAvailable(),
Expand All @@ -70,8 +79,11 @@ public static TransportType determineTransportMethod() {
if (isClassAvailable("io.netty.channel.kqueue.KQueue") && KQueue.isAvailable()) {
return new TransportType(
TransportMethod.KQUEUE,
KQueueServerSocketChannel.class,
KQueueServerSocketChannel::new,
KQueueSocketChannel.class,
KQueueSocketChannel::new,
KQueueDatagramChannel.class,
KQueueDatagramChannel::new,
factory -> new KQueueEventLoopGroup(0, factory),
KQueue.isTcpFastOpenServerSideAvailable(),
Expand All @@ -81,8 +93,11 @@ public static TransportType determineTransportMethod() {

return new TransportType(
TransportMethod.NIO,
NioServerSocketChannel.class,
NioServerSocketChannel::new,
NioSocketChannel.class,
NioSocketChannel::new,
NioDatagramChannel.class,
NioDatagramChannel::new,
factory -> new NioEventLoopGroup(0, factory),
false,
Expand Down

0 comments on commit de6bbe5

Please sign in to comment.