Interface SessionListener
- All Known Implementing Classes:
ClientListener,ServerListener,SessionAdapter
public interface SessionListener
A listener for listening to session events.
-
Method Summary
Modifier and TypeMethodDescriptionvoidCalled when a session connects.voiddisconnected(Session session, net.kyori.adventure.text.Component reason, Throwable cause) Called when a session is disconnected.voiddisconnecting(Session session, net.kyori.adventure.text.Component reason, Throwable cause) Called when a session is about to disconnect.booleanpacketError(Session session, Throwable throwable) Called when a session encounters an error while reading or writing packet data.voidpacketReceived(Session session, Packet packet) Called when a session receives a packet.packetSending(Session session, Packet packet) Called when a session is sending a packet.voidpacketSent(Session session, Packet packet) Called when a session sends a packet.
-
Method Details
-
packetReceived
Called when a session receives a packet.- Parameters:
packet- the packet that was just received.
-
packetSending
Called when a session is sending a packet.- Parameters:
session- Session sending the packet.packet- Packet being sent.- Returns:
- Packet to send, or null to cancel sending.
-
packetSent
Called when a session sends a packet.- Parameters:
packet- Packet just sent.
-
packetError
Called when a session encounters an error while reading or writing packet data.- Parameters:
session- Current sessionthrowable- Cause of the error.- Returns:
- Whether the error should be suppressed.
-
connected
Called when a session connects.- Parameters:
session- Session that connected.
-
disconnecting
Called when a session is about to disconnect.- Parameters:
session- Session being disconnected.reason- Reason for the session to disconnect.cause- Throwable that caused the disconnect, or null if not caused by a throwable.
-
disconnected
Called when a session is disconnected.- Parameters:
session- Session that disconnected.reason- Reason for the session to disconnect.cause- Throwable that caused the disconnect, or null if not caused by a throwable.
-