Class ClientDisconnectEvent
java.lang.Object
de.craftsblock.craftscore.event.Event
de.craftsblock.craftsnet.events.sockets.ClientDisconnectEvent
- All Implemented Interfaces:
GenericSocketEventBase
public class ClientDisconnectEvent
extends de.craftsblock.craftscore.event.Event
implements GenericSocketEventBase
The ClientDisconnectEvent class represents an event related to a client disconnection from a websocket connection.
It extends the base Event class and provides information about the SocketExchange and the SocketMapping associated with the disconnection event.
- Since:
- 2.1.1-SNAPSHOT
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionClientDisconnectEvent(SocketExchange exchange, int closeCode, String closeReason, boolean closeByServer) Constructs a new ClientDisconnectEvent with the specified SocketExchange and SocketMapping. -
Method Summary
Modifier and TypeMethodDescriptionGets the close code parsed to a ClosureCode why the connection was closed.Gets the reason why the connection was closed.@NotNull SocketExchangeGets theSocketExchangewhich stores the involved client, server and some other data.Gets aEnumMapof allRouteRegistry.EndpointMappingassociated with the client disconnect event.intGets the raw close code why the connection was closed.booleanChecks if the client disconnection event has at least one valid SocketMapping associated with it.booleanGets whether the server disconnected the client or the client disconnected.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.craftsblock.craftsnet.events.sockets.GenericSocketEventBase
getClient, getServer
-
Constructor Details
-
ClientDisconnectEvent
public ClientDisconnectEvent(SocketExchange exchange, int closeCode, String closeReason, boolean closeByServer) Constructs a new ClientDisconnectEvent with the specified SocketExchange and SocketMapping.- Parameters:
exchange- The SocketExchange object representing the socket connection and its associated data.closeCode- The close code.closeReason- The close reason.closeByServer- Whether the connection was closed by the server or the client.
-
-
Method Details
-
getExchange
Gets theSocketExchangewhich stores the involved client, server and some other data.- Specified by:
getExchangein interfaceGenericSocketEventBase- Returns:
- The
SocketExchange.
-
getMappings
Gets aEnumMapof allRouteRegistry.EndpointMappingassociated with the client disconnect event.- Returns:
- A
EnumMapofRouteRegistry.EndpointMappingobjects representing the mapping for the socket connection.
-
hasMappings
public boolean hasMappings()Checks if the client disconnection event has at least one valid SocketMapping associated with it.- Returns:
- true if the event has at least one valid SocketMapping, false otherwise.
-
getRawCloseCode
public int getRawCloseCode()Gets the raw close code why the connection was closed.- Returns:
- The raw close code if it was present, -1 otherwise
-
getCloseCode
Gets the close code parsed to a ClosureCode why the connection was closed.- Returns:
- The parsed close code if it was present, and it is registered in the ClosureCode enum, null otherwise
-
getCloseReason
Gets the reason why the connection was closed.- Returns:
- The close reason if it was present, null otherwise
-
wasClosedByServer
public boolean wasClosedByServer()Gets whether the server disconnected the client or the client disconnected.- Returns:
- true if the server closed the connection, false otherwise.
-