feat(socketio/state): global state implementation backed by a state::TypeMap
#194
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.
This PR adds global state management as well as a
State
extractor to get the state in any handlers.Note : Before merging this PR, it is necessary to use dynamics handler for the
on_disconnect
function. Otherwise it wont be possible to use the state in these handlers.Currently it is not possible to use the references in extractors because of the following problem :
In the
ConnectHandler
implementation below for any function with arguments that implementsFromConnectParts
and are specified by values. To add a lifetime to extractors we could add a lifetime on the traitFromConnectParts
. The problem is that the provided lifetime should be the one declared with thefor<'a>
corresponding to the function and its scope is rather limited.Because of this issue the state will be
static
so thatState
extractors only contains &'static references and don't need lifetime propagation.