public class FMLHandshakeHandler
extends java.lang.Object
An instance is created during CHandshakePacket handling, and attached
to the NetworkManager.channel via FMLNetworkConstants.FML_HANDSHAKE_HANDLER.
The FMLNetworkConstants.handshakeChannel is a SimpleChannel with standard messages flowing in both directions.
The loginWrapper transforms these messages into CCustomPayloadLoginPacket
and SCustomPayloadLoginPacket compatible messages, by means of wrapping.
The handshake is ticked tickLogin(NetworkManager) from the ServerLoginNetHandler#update() method,
utilizing the ServerLoginNetHandler.State#NEGOTIATING state, which is otherwise unused in vanilla code.
During client to server initiation, on the server, the NetworkEvent.GatherLoginPayloadsEvent is fired,
which solicits all registered channels at the NetworkRegistry for any
NetworkRegistry.LoginPayload they wish to supply.
The collected NetworkRegistry.LoginPayload are sent, one per tick, via
the FMLLoginWrapper.wrapPacket(ResourceLocation, PacketBuffer) mechanism to the incoming client connection. Each
packet is indexed via CCustomPayloadLoginPacket.transaction, which is
the only mechanism available for tracking request/response pairs.
Each packet sent from the server should be replied by the client, though not necessarily in sent order. The reply
should contain the index of the server's packet it is replying to. The FMLLoginWrapper class handles indexing
replies correctly automatically.
Once all packets have been dispatched, we wait for all replies to be received. Once all replies are received, the final login phase will commence.
| 修飾子とタイプ | メソッドと説明 |
|---|---|
static <MSG extends java.util.function.IntSupplier> |
biConsumerFor(ThreeConsumer<FMLHandshakeHandler,? super MSG,? super java.util.function.Supplier<NetworkEvent.Context>> consumer)
Transforms a two-argument instance method reference into a
BiConsumer based on the getHandshake(Supplier) function. |
static <MSG extends java.util.function.IntSupplier> |
indexFirst(ThreeConsumer<FMLHandshakeHandler,MSG,java.util.function.Supplier<NetworkEvent.Context>> next)
Transforms a two-argument instance method reference into a
BiConsumer biConsumerFor(ThreeConsumer), first calling the #handleIndexedMessage(FMLHandshakeMessages.LoginIndexedMessage, Supplier)
method to handle index tracking. |
boolean |
tickServer()
FML will send packets, from Server to Client, from the messages queue until the queue is drained.
|
public static <MSG extends java.util.function.IntSupplier> java.util.function.BiConsumer<MSG,java.util.function.Supplier<NetworkEvent.Context>> biConsumerFor(ThreeConsumer<FMLHandshakeHandler,? super MSG,? super java.util.function.Supplier<NetworkEvent.Context>> consumer)
BiConsumer based on the getHandshake(Supplier) function.
This should only be used for login message types.MSG - message typeconsumer - A two argument instance method referenceBiConsumer for use in message handlingpublic static <MSG extends java.util.function.IntSupplier> java.util.function.BiConsumer<MSG,java.util.function.Supplier<NetworkEvent.Context>> indexFirst(ThreeConsumer<FMLHandshakeHandler,MSG,java.util.function.Supplier<NetworkEvent.Context>> next)
BiConsumer biConsumerFor(ThreeConsumer), first calling the #handleIndexedMessage(FMLHandshakeMessages.LoginIndexedMessage, Supplier)
method to handle index tracking. Used for client to server replies.
This should only be used for login messages.MSG - message typenext - The method reference to call after index handlingBiConsumer for use in message handlingpublic boolean tickServer()