Interface ServerLoginNetworking.LoginSynchronizer
- All Superinterfaces:
org.quiltmc.qsl.networking.api.ServerLoginNetworking.LoginSynchronizer
- Enclosing class:
ServerLoginNetworking
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@Deprecated
@FunctionalInterface
public static interface ServerLoginNetworking.LoginSynchronizer
extends org.quiltmc.qsl.networking.api.ServerLoginNetworking.LoginSynchronizer
Deprecated.
Allows blocking client log-in until all futures passed into
waitFor(Future) are completed.- API Note:
- this interface is not intended to be implemented by users of api.
-
Method Summary
-
Method Details
-
waitFor
Deprecated.Allows blocking client log-in until thefutureisdone.Since packet reception happens on netty's event loops, this allows handlers to perform logic on the Server Thread, etc. For instance, a handler can prepare an upcoming query request or check necessary login data on the server thread.
Here is an example where the player log-in is blocked so that a credential check and building of a followup query request can be performed properly on the logical server thread before the player successfully logs in:
Usually it is enough to pass the return value forServerLoginNetworking.registerGlobalReceiver(CHECK_CHANNEL, (server, handler, understood, buf, synchronizer, responseSender) -> { if (!understood) { handler.disconnect(Text.literal("Only accept clients that can check!")); return; } String checkMessage = buf.readString(32767); // Just send the CompletableFuture returned by the server's submit method synchronizer.waitFor(server.submit(() -> { LoginInfoChecker checker = LoginInfoChecker.get(server); if (!checker.check(handler.getConnectionInfo(), checkMessage)) { handler.disconnect(Text.literal("Invalid credentials!")); return; } responseSender.send(UPCOMING_CHECK, checker.buildSecondQueryPacket(handler, checkMessage)); })); });ThreadExecutor.submit(Runnable)forfuture.- Specified by:
waitForin interfaceorg.quiltmc.qsl.networking.api.ServerLoginNetworking.LoginSynchronizer- Parameters:
future- the future that must be done before the player can log in
-