Commit Graph
132 Commits
Author SHA1 Message Date
Térence Clastres 1db412e970 Fix high CPU usage when running the SDK server
It was coming from `recv_select()` and `accept_select()`
The timeval struct members for select() is reset after each call to select() for
whatever reason so like FD_ZERO and FD_SET it needs to be placed inside
the loop.

Source: https://stackoverflow.com/questions/3324078/why-select-always-return-0-after-the-first-timeout
2020-06-24 10:08:40 -05:00
Térence Clastres b94f701db8 Fix high CPU usage when running the SDK server
It was coming from `recv_select()` `nd accept_select()`
The timeout for select() is only when waiting for the file descriptor to
be ready for reading/writing so when the FD is ready AND there is
nothing to read, it will not return and instead keep executing the while loop with no timeout.
Fix this by adding a 100ms timeout when there is nothing to read.
2020-06-24 09:35:31 -05:00
Térence Clastres b79ff124e6 Replace Sleep() by std::thread::sleep_for() 2020-06-24 09:28:11 -05:00
Adam Honse 0464fbcbe2 Make default SDK port a defined constant 2020-06-22 11:32:32 -05:00
Térence Clastres 6d585d3eeb Network: Print used port on startup and change default to 6742
Also print an error if server can't be started

1337 is already used by razer's rest server
Port idea by @bahorn (6742 = ORGB on a phone numpad)
2020-06-20 14:39:14 -05:00
Adam Honse e6aadc414b Handle socket errors on Windows, which does not return 0 when a socket is disconnected like Linux does 2020-05-10 16:22:29 -05:00
Matt Harper 69e1e19bf9 Bugfix - properly free ServerClients 2020-05-09 17:30:54 -05:00
Adam Honse 352b9928ca Add file headers to network files and some minor code cleanup 2020-05-09 15:48:16 -05:00
Adam Honse 6438c15dd3 Fix build on Windows 2020-05-09 15:48:16 -05:00
Adam Honse a5e9a3de05 Add mutex on updating callbacks 2020-05-09 15:48:15 -05:00
Adam Honse edf1b251c0 Send and receive client string 2020-05-09 15:48:15 -05:00
Adam Honse 9ff4314840 Add callback to NetworkServer to handle UI updates when client information changes 2020-05-09 15:48:15 -05:00
Adam Honse 3ad0986ae7 Add IP field to client information and display client IP in the server tab's connected client list 2020-05-09 15:48:15 -05:00
Adam Honse 6bfc9dd9db Create a structure to hold client information in the network server and fix i2c hanging on destructor when bus is not available. 2020-05-09 15:48:15 -05:00
Adam Honse 119741b736 Fix build on Windows 2020-05-09 15:48:15 -05:00
Adam Honse 2fe958783c Use select on accept call as well so that server closes on Linux 2020-05-09 15:48:15 -05:00
Adam Honse 9e44e4ba4f Add server information to user interface and provide buttons to start and stop server, change port 2020-05-09 15:48:15 -05:00
Adam Honse 81acc47cd6 Use std::thread for NetworkServer threads 2020-05-09 15:48:14 -05:00
Adam Honse 25f7a87a79 Get network server working in Windows 2020-05-09 15:48:14 -05:00
Adam Honse 4d6706ce61 Close server listener thread when read returns zero (client connection lost) 2020-05-09 15:48:13 -05:00
Adam Honse 39c5aff864 Send color data over the network when calling color update functions 2020-05-09 15:48:13 -05:00
Adam Honse 450f438538 Send mode data block when updating mode 2020-05-09 15:48:13 -05:00
Adam Honse 0270c745ce Implement RGBController_Network packet sending for current set of RGBController commands 2020-05-09 15:48:13 -05:00
Adam Honse 68fa3c2def Create functions for sending replies 2020-05-09 15:48:13 -05:00
Adam Honse 7c1a1396ca Client requests controller count and first controller data block from server, prints response 2020-05-09 15:48:13 -05:00
Adam Honse dff667751b Start work on network client 2020-05-09 15:48:12 -05:00
Adam Honse 2625807c1a Add RGBController function call packet functionality 2020-05-09 15:48:12 -05:00
Adam Honse 7af283fdbf Implement requests for number of controllers and controller information block 2020-05-09 15:48:12 -05:00
Adam Honse c7ffe3b926 Network server can now receive packets properly 2020-05-09 15:48:12 -05:00
Adam Honse 46339c5f86 More work on network support, need to implement spawning of one read thread for each client socket 2020-05-09 15:48:12 -05:00
Adam Honse cf69598fd1 Start working on server request processing code 2020-05-09 15:48:12 -05:00
Adam Honse 594f66ab23 Initial network files 2020-05-09 15:48:12 -05:00