feat: allow closing a WebSocket server outside of the ServerCloseable #279
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Allows for not managing closing of the WebSocket server externally from the ServerCloseable.
Motivation:
In my use case I provide an existing WebSocket server using the
wsCreator
factory. This server's lifecycle is managed externally.In the current implementation if I close my WebSocket server externally then the
close
listener will trigger theServerCloseable
'sclose
method which will attempt to close the server again which will fire anotherclose
event and trigger theServerCloseable
'sclose
method for a second time: this prints a warning for attempting to close for the second time.Modifications:
I've added an option to externally manage closing of the server. This will optionally prevent the
ServerCloseable
from closing the server.Result:
An additional option will be available when creating a
WebSocketServerTransport
. If this option is enabled the WebSocketServer should be closed externally.