Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement: Replace 'fd' with 'ws_cli_conn_t' throughout the code
This commit changes the use of the 'fd' parameter of the wsServer's API and replaces it with a pointer of type 'ws_cli_conn_t'. This change brings multiple benefits to the source code: a) The 'fd' could confuse the user and cause them to use it in other POSIX routines that accept a file descriptor. b) Sharing the 'fd' through various functions and iterating over the list of clients to get the structure of it sounds completely pointless. Therefore, the natural solution is to share the pointer relative to the client's connection structure, which improves code complexity, readability, and reduces the amount of LOCs. -- Furthermore, this commit also changes the way broadcast messages are sent: previously, to send a broadcast it was necessary to know the 'fd' of a valid connected client, which also doesn't make sense. Therefore, the signing of the ws_sendframe* functions has been simplified, and the 'broadcast' parameter is no longer needed. If the recipient is null, the message is a broadcast. --- Note: The multi-port listening feature has been removed in order to make the broadcast mechanism simpler. However, I intend reintroduce it in the future by removing all public variables and leaving the event frame bound to a 'struct ws_server'.
- Loading branch information
Showing
4 changed files
with
245 additions
and
329 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.