Class SessionDefineNetworkChannelsEvent
- All Implemented Interfaces:
org.geysermc.event.Event
It is important to note that this event may be called multiple times during a
session's lifecycle, as channels can be registered at different stages of the connection.
It is always important to check the SessionDefineNetworkChannelsEvent.State of the connection through state()
before registering channels to avoid creating multiple listeners that are only intended
to be registered once.
It is typically advised to register channels at the SessionDefineNetworkChannelsEvent.State.LOGGED_IN state unless
creating a developer tool, such as a packet logger. This is the latest point at which channels
can be registered, and is when clients will be fully established. Registering earlier means
certain client information is unavailable or potentially unverified (i.e., Bedrock usernames).
Registering at earlier points also increases the intensity of an L7 attack as the client is in a far earlier stage of the connection and therefore more vulnerable to invalid clients early in the connection stage. However, for debug tools that will never be used in a production environment, registering at earlier stages can be useful to capture more information about the connection and the client's behavior during earlier stages of the connection.
- Since:
- 2.9.2
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceSessionDefineNetworkChannelsEvent.Builder<M extends Message<? extends MessageBuffer>>Registration builder for attaching handlers to a channel.static interfaceSessionDefineNetworkChannelsEvent.Registration<M extends Message<? extends MessageBuffer>>static enumThe state of the connection at the time of channel registration. -
Constructor Summary
ConstructorsConstructorDescriptionSessionDefineNetworkChannelsEvent(GeyserConnection connection, SessionDefineNetworkChannelsEvent.State state) -
Method Summary
Modifier and TypeMethodDescriptionabstract <T extends MessageBuffer,M extends Message<T>>
SessionDefineNetworkChannelsEvent.Builder.Initial<M> define(NetworkChannel channel, MessageCodec<T> codec, MessageFactory<T, M> messageFactory) Defines the registration of a new network channel with a codec and message factory.abstract <M extends Message<MessageBuffer>>
SessionDefineNetworkChannelsEvent.Builder.Initial<M> define(NetworkChannel channel, MessageFactory<MessageBuffer, M> messageFactory) Defines the registration of a new network channel with a message factory.state()Gets the state of the connection at the time of channel registration.Methods inherited from class org.geysermc.geyser.api.event.connection.ConnectionEvent
connection
-
Constructor Details
-
SessionDefineNetworkChannelsEvent
public SessionDefineNetworkChannelsEvent(GeyserConnection connection, SessionDefineNetworkChannelsEvent.State state)
-
-
Method Details
-
state
Gets the state of the connection at the time of channel registration.- Returns:
- the registration state
-
define
public abstract <M extends Message<MessageBuffer>> SessionDefineNetworkChannelsEvent.Builder.Initial<M> define(NetworkChannel channel, MessageFactory<MessageBuffer, M> messageFactory) Defines the registration of a new network channel with a message factory.- Type Parameters:
M- the message type created by the factory- Parameters:
channel- the channel to registermessageFactory- the factory used to create messages from the buffer- Returns:
- a registration builder to configure handlers
-
define
public abstract <T extends MessageBuffer,M extends Message<T>> SessionDefineNetworkChannelsEvent.Builder.Initial<M> define(NetworkChannel channel, MessageCodec<T> codec, MessageFactory<T, M> messageFactory) Defines the registration of a new network channel with a codec and message factory.- Type Parameters:
T- the buffer typeM- the message type created by the factory- Parameters:
channel- the channel to registercodec- the codec to use to encode/decode the buffermessageFactory- the factory used to create messages from the buffer- Returns:
- a registration builder to configure handlers
-