Class NetherNetDiscovery
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.SimpleChannelInboundHandler<io.netty.channel.socket.DatagramPacket>
org.cloudburstmc.netty.channel.nethernet.signaling.NetherNetDiscovery
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler
public class NetherNetDiscovery
extends io.netty.channel.SimpleChannelInboundHandler<io.netty.channel.socket.DatagramPacket>
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Constructor Summary
ConstructorsConstructorDescriptionNetherNetDiscovery(long networkId) Creates a NetherNetDiscovery instance with the specified Network ID. -
Method Summary
Modifier and TypeMethodDescriptionvoidbind()voidbind(int port) voidbind(InetSocketAddress address) Opens the discovery socket on a loop of its own, whichclose()shuts down.protected voidchannelRead0(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.socket.DatagramPacket packet) voidclose()booleanisActive()voidregisterSignalHandler(String connectionId, NetherNetSignaling.SignalHandler handler) voidsendDiscoveryRequest(InetSocketAddress target, BiConsumer<Long, io.netty.buffer.ByteBuf> onServerFound) voidsendSignal(long targetNetworkId, String data) voidsendSignal(InetSocketAddress recipient, long targetNetworkId, String data) io.netty.util.concurrent.ScheduledFuture<?>sendSignalRetrying(InetSocketAddress recipient, long targetNetworkId, String data, long delayMs) Sends a signal immediately and schedules it to be resent periodically until the returned ScheduledFuture is cancelled.voidsetMotdProvider(MotdProvider provider) Asksproviderfor the pong on every discovery request, so it follows the player count.voidvoidsetPongData(PongData data) Answers every discovery request withdata.voidunregisterSignalHandler(String connectionId) Methods inherited from class io.netty.channel.SimpleChannelInboundHandler
acceptInboundMessage, channelReadMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Constructor Details
-
NetherNetDiscovery
public NetherNetDiscovery(long networkId) Creates a NetherNetDiscovery instance with the specified Network ID.- Parameters:
networkId- The Network ID to use for discovery.
-
-
Method Details
-
bind
public void bind() -
bind
public void bind(int port) -
bind
Opens the discovery socket on a loop of its own, whichclose()shuts down. -
sendDiscoveryRequest
public void sendDiscoveryRequest(InetSocketAddress target, BiConsumer<Long, io.netty.buffer.ByteBuf> onServerFound) -
setPongData
Answers every discovery request withdata. -
setMotdProvider
Asksproviderfor the pong on every discovery request, so it follows the player count. It runs on the discovery loop with no host or client info, and a null answer leaves the request unanswered. -
registerSignalHandler
-
unregisterSignalHandler
-
setNewConnectionHandler
-
sendSignalRetrying
public io.netty.util.concurrent.ScheduledFuture<?> sendSignalRetrying(InetSocketAddress recipient, long targetNetworkId, String data, long delayMs) Sends a signal immediately and schedules it to be resent periodically until the returned ScheduledFuture is cancelled. -
sendSignal
-
sendSignal
-
channelRead0
protected void channelRead0(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.socket.DatagramPacket packet) throws Exception - Specified by:
channelRead0in classio.netty.channel.SimpleChannelInboundHandler<io.netty.channel.socket.DatagramPacket>- Throws:
Exception
-
close
public void close() -
isActive
public boolean isActive()
-