You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How can I create a list of connected clients using the wsServer library? (question) #70
I am currently working with the wsServer library and I am trying to achieve two tasks. First, I need to create a list of connected clients. Second, I want to broadcast a message to some of the clients on the list based on their file descriptor (FD).
I attempted to create an array of connected clients using the syntax ws_cli_cont clients[size]. However, I received an error message indicating that ws_cli_cont is not a complete type. I am not sure if this is the correct way to create an array of connected clients.
Additionally, I need to differentiate between clients based on their FD to broadcast a message only to a specific group of clients. Can someone guide me on the proper way to create a list of connected clients and broadcast a message based on FD using the wsServer library? Any advice or code examples would be greatly appreciated.
Activity
raspberry-pi-maker commentedon Feb 28, 2023
I think you should use pointer type like ws_cli_cont *clients[size].
In the onopen callback, you can add the pointer to the array.
In the onclose callback, you should remove the pointer from the array.
I havn't tested this code. But I think this code could help you
Sarang0218 commentedon Feb 28, 2023
Thanks, I’ll check this out as soon as I return home.
Sarang0218 commentedon Feb 28, 2023
Works Great!