Add an option for TCP-only mode

This commit is contained in:
Patrick Nicolas
2024-05-16 17:44:49 +02:00
parent 111afd4737
commit 0ce74f5e80
4 changed files with 30 additions and 2 deletions
+13
View File
@@ -146,3 +146,16 @@ An application to start when connection with the headset is established, can be
}
```
Launch No Man's Sky in VR mode on Steam when connection with headset is established.
## `tcp_only`
Default value: `false`
Only use TCP for communications with the client, this may have increased latency.
If `false` or unset, WiVRn will use both TCP and UDP.
### Example
```json
{
"tcp_only": true
}
```
+5
View File
@@ -117,6 +117,11 @@ configuration configuration::read_user_configuration()
}
}
}
if (json.contains("tcp_only"))
{
result.tcp_only = json["tcp_only"];
}
}
catch (const std::exception & e)
{
+1
View File
@@ -45,6 +45,7 @@ struct configuration
std::optional<int> bitrate;
std::optional<std::array<double, 2>> scale;
std::vector<std::string> application;
bool tcp_only = false;
static configuration read_user_configuration();
};
+11 -2
View File
@@ -18,6 +18,7 @@
*/
#include "wivrn_connection.h"
#include "configuration.h"
#include "util/u_logging.h"
#include <arpa/inet.h>
#include <poll.h>
@@ -25,7 +26,7 @@
using namespace std::chrono_literals;
wivrn_connection::wivrn_connection(TCP && tcp) :
control(std::move(tcp))
control(std::move(tcp)), stream(-1)
{
sockaddr_in6 server_address;
socklen_t len = sizeof(server_address);
@@ -45,7 +46,15 @@ wivrn_connection::wivrn_connection(TCP && tcp) :
// Wait for client to send handshake
auto timeout = std::chrono::steady_clock::now() + std::chrono::seconds(10);
stream.bind(port);
if (configuration::read_user_configuration().tcp_only)
{
port = -1;
}
else
{
stream = decltype(stream)();
stream.bind(port);
}
control.send(to_headset::handshake{.stream_port = port});