Class WebSocketExtensionRegistry
java.lang.Object
de.craftsblock.craftsnet.api.websocket.extensions.WebSocketExtensionRegistry
Registry for managing WebSocket extensions. This class allows for the registration,
unregistration, and lookup of WebSocket extensions by their protocol names. It is designed
to be thread-safe, using a concurrent hash map to store the extensions.
- Since:
- 3.0.6-SNAPSHOT
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new WebSocket extension registry and registers the default extensions. -
Method Summary
Modifier and TypeMethodDescriptiongetExtensionByName(String protocolName) Retrieves a WebSocket extension by its protocol name.Retrieves all registered WebSocket extensions.booleanhasExtension(WebSocketExtension extension) Checks if a WebSocket extension is registered by its instance.booleanhasExtension(String protocolName) Checks if a WebSocket extension is registered by its protocol name.voidregister(WebSocketExtension extension) Registers a new WebSocket extension.voidunregister(WebSocketExtension extension) Unregisters a WebSocket extension by its instance.voidunregister(String protocolName) Unregisters a WebSocket extension by its protocol name.
-
Constructor Details
-
WebSocketExtensionRegistry
public WebSocketExtensionRegistry()Constructs a new WebSocket extension registry and registers the default extensions.
-
-
Method Details
-
register
Registers a new WebSocket extension. If an extension with the same protocol name already exists, it will be replaced.- Parameters:
extension- the WebSocket extension to be registered. Must not be null.
-
unregister
Unregisters a WebSocket extension by its instance. This method callsunregister(String)with the protocol name of the given extension.- Parameters:
extension- the WebSocket extension to be unregistered. Must not be null.
-
unregister
Unregisters a WebSocket extension by its protocol name. If no extension with the given protocol name is registered, this method does nothing.- Parameters:
protocolName- the protocol name of the WebSocket extension to be unregistered. Must not be null.
-
hasExtension
Checks if a WebSocket extension is registered by its instance. This method callshasExtension(String)with the protocol name of the given extension.- Parameters:
extension- the WebSocket extension to check. Must not be null.- Returns:
trueif the extension is registered,falseotherwise.
-
hasExtension
Checks if a WebSocket extension is registered by its protocol name.- Parameters:
protocolName- the protocol name of the WebSocket extension to check. Must not be null.- Returns:
trueif the extension is registered,falseotherwise.
-
getExtensionByName
Retrieves a WebSocket extension by its protocol name.- Parameters:
protocolName- the protocol name of the WebSocket extension to retrieve. Must not be null.- Returns:
- the WebSocket extension associated with the given protocol name, or
nullif no such extension is registered.
-
getExtensions
Retrieves all registered WebSocket extensions.- Returns:
- a concurrent linked queue containing all registered WebSocket extensions.
-