Commit Graph

55 Commits

Author SHA1 Message Date
B Horn
a54f03e199 Fixing MacOS / Clang builds 2022-07-18 02:32:28 +00:00
B Horn
640eb7905c SDK Listening Options 2022-07-17 20:30:15 +00:00
Chris
f3eac499d4 Allow for server side controller resizing
* Save sizes profile on the server
* Update RGBController_Network size on the client
2022-07-04 20:16:39 +00:00
Alex
4af8614fce Add formated loging for device detection
Commits merged and amended for code style by Adam Honse <calcprogrammer1@gmail.com>
2021-07-05 03:23:34 -05:00
Adam Honse
5130f07e21 Add saving support to network protocol 2021-07-04 21:17:55 -05:00
Chris
a46eccef3c Added brightness to profile loading and saving
* Bumped profile version to 3
* Loading a v1/v2 profile onto a device with brightness will work
* Loading a v3 profile onto a device without brightness also works
* Add profile version parameter to Get/SetModeDescription

Commit amended for code style and to update versioning by Adam Honse <calcprogrammer1@gmail.com>
2021-07-04 21:16:56 -05:00
k1-801
65623d3978 Autoclose updated
Commit amended for code style by Adam Honse <calcprogrammer1@gmail.com>
2021-05-24 22:45:24 -05:00
k1-801
abfb6ea22d Tiny fixups (server conn info leak closed, log va leak closed, config dir optimized)
Commit amended for code style by Adam Honse <calcprogrammer1@gmail.com>
2021-05-24 22:41:12 -05:00
k1-801
02ba8a799e Server freed from ResourceManager
Commit amended to revert OpenRGBInterfaces.h header (may reconsider in the future) by Adam Honse
<calcprogrammer1@gmail.com>
2021-05-13 22:10:41 -05:00
Gabriel Marcano
30f88d5fcf Fix mismatched new[] / delete
- The device description buffer was allocated using new[] in
   RGBController. Make sure to free it using delete[].
2021-05-05 02:07:19 -07:00
morg
8ef9f622f1 Fix memory leak (RGBController::GetDeviceDescription) 2021-03-27 22:15:24 +01:00
morg
79dacbaeb0 Fix crash on server stop
Commit amended to initialize listening variable by Adam Honse <calcprogrammer1@gmail.com>
2021-02-09 16:34:25 -06:00
morg
e2bc1003e6 Add profile management to SDK
Commit amended for code style by Adam Honse <calcprogrammer1@gmail.com>
2021-02-05 19:13:50 -06:00
Adam Honse
72da8f362c SDK protocol versioning implemented. Protocol updated to version 1 which adds vendor string to controller request. 2020-12-01 21:02:32 -06:00
k1-801
dde857dfb4 Tiny threads fixes & a little bit of safety 2020-11-15 13:28:29 -06:00
Adam Honse
c3b4489fd3 Fix Windows build 2020-09-27 23:19:59 -05:00
Adam Honse
60fd721586 Server sends a request to the client when the device list is updated 2020-09-27 22:12:34 +00:00
Adam Honse
f568253c51 Clean up more warnings 2020-09-02 18:25:58 -05:00
k1-801
8b8451017e Non-important warnings removed
Commit amended by Adam Honse <calcprogrammer1@gmail.com> due to merging from a different branch.
2020-09-01 23:29:00 -05:00
B Horn
f02223d6ba Checks to avoid null dereferences in NetworkServer
Various commands in NetworkServer require extra data. However, if the
packet size is set to 0 for these, the code will skip over reading the
data in and allocating memory. This results in null dereferences.

This patch adds checks to the relevant commands to make sure they don't
continue reading a null pointer.
2020-07-19 13:16:19 -05:00
Adam Honse
0ccf2d0c33 Remove some debugging printouts in Network Client and Server code 2020-07-17 22:10:53 -05:00
B Horn
47baeb6b6b Improving NetworkServer's memory management (#373)
This patch resolves several bugs:

* NetworkServer would allocate various instances of `NetworkClientInfo`.
  This is patched by deallocating the NetworkClientInfo when it's
  listening thread ends in the `listen_done` section.

* Memory would be allocated for threads that wouldn't be freed. This
  is resolved by detaching from the threads, so they no longer need to
  be joined to be freed, and then freeing the memory as they finish.

* Thread-Safety issues involving `ServerClients` would result in stray
  `NetworkClientInfo`'s not being removed from the list in certain
  situations. This is resolved by used a mutex to lock access to this
  from different threads.
2020-07-09 21:56:42 -05:00
Adam Honse
96af869d79 Check for local server before detecting devices from hardware and tweak timeouts to make network connections faster 2020-06-28 21:08:59 -05:00
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