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:
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Set<Identifier>
Gets all query request channel names which global receivers are registered for.static boolean
registerGlobalReceiver
(Identifier channelName, ClientLoginNetworking.LoginQueryRequestHandler queryHandler) Registers a handler to a query request channel.static boolean
registerReceiver
(Identifier channelName, ClientLoginNetworking.LoginQueryRequestHandler queryHandler) Registers a handler to a query request channel.unregisterGlobalReceiver
(Identifier channelName) Removes the handler of a query request channel.unregisterReceiver
(Identifier channelName) Removes the handler of a query request channel.
-
Method Details
-
registerGlobalReceiver
public static boolean registerGlobalReceiver(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
@Nullable public static ClientLoginNetworking.LoginQueryRequestHandler unregisterGlobalReceiver(Identifier channelName) Removes the handler of a query request channel. A global receiver is registered to all connections, in the present and future.The
channel
is guaranteed not to have a handler after this call.- Parameters:
channelName
- the id of the channel- Returns:
- the previous handler, or
null
if no handler was bound to the channel - See Also:
-
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(Identifier channelName, ClientLoginNetworking.LoginQueryRequestHandler queryHandler) throws IllegalStateException Registers 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(Identifier channelName) throws IllegalStateException Removes the handler of a query request channel.The
channelName
is guaranteed not to have a handler after this call.- Parameters:
channelName
- the id of the channel- Returns:
- the previous handler, or
null
if no handler was bound to the channel name - Throws:
IllegalStateException
- if the client is not logging in
-