add wivrn+tcp scheme

This commit is contained in:
galister
2024-09-18 18:18:00 +02:00
committed by xytovl
parent 9a39f24541
commit 801bc5bd65
9 changed files with 28 additions and 11 deletions
+6 -6
View File
@@ -49,7 +49,7 @@ void init_stream(T & stream)
} // namespace
template <typename T>
void wivrn_session::handshake(T address)
void wivrn_session::handshake(T address, bool tcp_only)
{
// Wait for handshake on control socket,
// then send ours on stream or control socket,
@@ -75,7 +75,7 @@ void wivrn_session::handshake(T address)
try
{
auto h = std::get<to_headset::handshake>(*packet);
if (h.stream_port > 0)
if (h.stream_port > 0 && !tcp_only)
{
stream = decltype(stream)();
stream.connect(address, h.stream_port);
@@ -113,18 +113,18 @@ void wivrn_session::handshake(T address)
}
}
wivrn_session::wivrn_session(in6_addr address, int port) :
wivrn_session::wivrn_session(in6_addr address, int port, bool tcp_only) :
control(address, port), stream(-1), address(address)
{
char buffer[100];
spdlog::info("Connection to {}:{}", inet_ntop(AF_INET6, &address, buffer, sizeof(buffer)), port);
handshake(address);
handshake(address, tcp_only);
}
wivrn_session::wivrn_session(in_addr address, int port) :
wivrn_session::wivrn_session(in_addr address, int port, bool tcp_only) :
control(address, port), stream(-1), address(address)
{
char buffer[100];
spdlog::info("Connection to {}:{}", inet_ntop(AF_INET, &address, buffer, sizeof(buffer)), port);
handshake(address);
handshake(address, tcp_only);
}