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.
Description
A few days ago I was asked why wsServer only sends broadcast messages if it knows a client beforehand (its 'fd'). Clearly this is an issue as the broadcast must work without the prior knowledge of any connected users.
This PR therefore fixes this bug by changing the signature of the ws_sendframe* routines: if a client is present, send only to it, otherwise broadcast.
In addition, the 'fd' parameter present in the API functions was replaced with 'ws_cli_conn_t', which made the code more intuitive and also allowed a great internal cleaning of the source code.
The new function signatures:
and the events:
A huge thanks to @tinkering4fun and @troglobytor for the discussion over the last few days on how I should approach this issue. I'm happy with the result and hope it meets your expectations.
Feel free whenever you want to suggest something... open an issue, discussion, PR... I'm always trying to listen to the community and adapt wsServer to their needs.