Class NeonRelay
java.lang.Object
com.quietterminal.neon.core.AbstractLifecycle
com.quietterminal.neon.relay.NeonRelay
- All Implemented Interfaces:
Lifecycle, AutoCloseable
UDP relay server for the Neon multiplayer protocol.
A NeonRelay routes packets between session hosts and clients. It manages session
state, enforces per-source rate limits, and handles the connection and reconnection handshake
on behalf of the host.
The relay is stateless with respect to game logic — it only understands the protocol
lifecycle packets (CONNECT_REQUEST, CONNECT_ACCEPT, etc.) and routes everything
else based on the destination ID in the packet header.
Typical deployment:
NeonRelay relay = new NeonRelay("0.0.0.0", NeonConfig.defaults());
Thread.ofVirtual().start(relay::startAndRun);
-
Nested Class Summary
Nested classes/interfaces inherited from interface Lifecycle
Lifecycle.State -
Constructor Summary
ConstructorsConstructorDescriptionNeonRelay(String bindAddress, NeonConfig config) Creates a relay bound to the given address on the port specified byNeonConfig.getRelayPort(). -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected voiddoStart()protected voiddoStop()Returns the local address the relay is bound to.voidStarts the relay and runs the packet processing loop untilAbstractLifecycle.stop()is called.Methods inherited from class AbstractLifecycle
getState, isRunning, start, stop
-
Constructor Details
-
NeonRelay
Creates a relay bound to the given address on the port specified byNeonConfig.getRelayPort().- Parameters:
bindAddress- IP address to bind (e.g."0.0.0.0"for all interfaces)config- protocol configuration- Throws:
IOException- if the socket cannot be bound
-
-
Method Details
-
doStart
protected void doStart()- Specified by:
doStartin classAbstractLifecycle
-
doStop
- Specified by:
doStopin classAbstractLifecycle- Throws:
IOException
-
startAndRun
Starts the relay and runs the packet processing loop untilAbstractLifecycle.stop()is called. Intended to run in a dedicated virtual thread.- Throws:
Exception- if startup fails
-
getLocalAddress
Returns the local address the relay is bound to.- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-