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.
Add support for socket activation
Description
Added new constructor to WebSocketServer which takes an already prepared Channel.
If this constructor is used, then WebSocketServer will not try to open it's own channel, or bind it since it is expected to be handled by user.
This allows to use System.inheritedChannel() together with systemd socket activation, which passes the prepared socket as file descriptor #0.
Also added an example "smart" chat server, which will be brought up and down on-demand by systemd.
I have tested it and it is working as expected.
TODO: a unit test should be added which creates server with an existing Channel.
I am also considering adding a script for running an integration test in a container, to make sure socket activation works as expected with this feature.
Related Issue
Fixes #1440
Motivation and Context
Allows to use socket activation with websockets
How Has This Been Tested?
I ran the new example which is in
src/main/example
as a systemd unit. Server comes up and down as expected.Types of changes
Checklist: