Class ClientLoginNetworking
java.lang.Object
net.fabricmc.fabric.api.client.networking.v1.ClientLoginNetworking
Offers access to login stage client-side networking functionalities.
The Minecraft login protocol only allows the client to respond to a server's request, but not initiate one of its own.
- See Also:
ClientPlayNetworking,ServerLoginNetworking
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic Set<net.minecraft.util.Identifier>Gets all query request channel names which global receivers are registered for.static booleanregisterGlobalReceiver(net.minecraft.util.Identifier channelName, ClientLoginNetworking.LoginQueryRequestHandler queryHandler)Registers a handler to a query request channel.static booleanregisterReceiver(net.minecraft.util.Identifier channelName, ClientLoginNetworking.LoginQueryRequestHandler queryHandler)Registers a handler to a query request channel.unregisterGlobalReceiver(net.minecraft.util.Identifier channelName)Removes the handler of a query request channel.static @Nullable ClientLoginNetworking.LoginQueryRequestHandlerunregisterReceiver(net.minecraft.util.Identifier channelName)Removes the handler of a query request channel.
-
Method Details
-
registerGlobalReceiver
public static boolean registerGlobalReceiver(net.minecraft.util.Identifier channelName, ClientLoginNetworking.LoginQueryRequestHandler queryHandler)Registers a handler to a query request channel. A global receiver is registered to all connections, in the present and future.If a handler is already registered to the
channel, this method will returnfalse, and no change will be made. UseunregisterGlobalReceiver(Identifier)to unregister the existing handler.- Parameters:
channelName- the id of the channelqueryHandler- the handler- Returns:
- false if a handler is already registered to the channel
- See Also:
unregisterGlobalReceiver(Identifier),registerReceiver(Identifier, LoginQueryRequestHandler)
-
unregisterGlobalReceiver
@Nullable public static ClientLoginNetworking.LoginQueryRequestHandler unregisterGlobalReceiver(net.minecraft.util.Identifier channelName)Removes the handler of a query request channel. A global receiver is registered to all connections, in the present and future.The
channelis guaranteed not to have a handler after this call.- Parameters:
channelName- the id of the channel- Returns:
- the previous handler, or
nullif no handler was bound to the channel - See Also:
registerGlobalReceiver(Identifier, LoginQueryRequestHandler),unregisterReceiver(Identifier)
-
getGlobalReceivers
Gets all query request channel names which global receivers are registered for. A global receiver is registered to all connections, in the present and future.- Returns:
- all channel names which global receivers are registered for.
-
registerReceiver
public static boolean registerReceiver(net.minecraft.util.Identifier channelName, ClientLoginNetworking.LoginQueryRequestHandler queryHandler) throws IllegalStateExceptionRegisters a handler to a query request channel.If a handler is already registered to the
channelName, this method will returnfalse, and no change will be made. UseunregisterReceiver(Identifier)to unregister the existing handler.- Parameters:
channelName- the id of the channelqueryHandler- the handler- Returns:
- false if a handler is already registered to the channel name
- Throws:
IllegalStateException- if the client is not logging in
-
unregisterReceiver
@Nullable public static @Nullable ClientLoginNetworking.LoginQueryRequestHandler unregisterReceiver(net.minecraft.util.Identifier channelName) throws IllegalStateExceptionRemoves the handler of a query request channel.The
channelNameis guaranteed not to have a handler after this call.- Parameters:
channelName- the id of the channel- Returns:
- the previous handler, or
nullif no handler was bound to the channel name - Throws:
IllegalStateException- if the client is not logging in
-