use broadcast address
This commit is contained in:
parent
3d38302e2f
commit
0745b725a7
5 changed files with 12 additions and 11 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
.idea
|
||||
cmake-build-*
|
||||
assets
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
FROM alpine:latest
|
||||
|
||||
RUN apk add gcc g++ cmake ninja
|
||||
RUN apk add mpg123-dev openssl-dev portaudio-dev
|
||||
RUN apk add mpg123-dev openssl-dev alsa-lib alsa-utils portaudio-dev pulseaudio-alsa alsa-plugins-pulse pulseaudio pulseaudio-utils
|
||||
|
||||
RUN echo "pcm.!default pulse\nctl.!default pulse" > /root/.asoundrc
|
||||
|
||||
WORKDIR /app
|
||||
COPY . /app
|
||||
|
|
|
@ -40,7 +40,7 @@ EventManager::EventManager() {
|
|||
|
||||
// hints for the communication
|
||||
addrinfo addressHints {};
|
||||
addressHints.ai_family = AF_INET; // TODO: AF_INET6
|
||||
addressHints.ai_family = AF_INET6;
|
||||
addressHints.ai_socktype = SOCK_DGRAM;
|
||||
addressHints.ai_protocol = IPPROTO_UDP;
|
||||
|
||||
|
@ -57,7 +57,7 @@ EventManager::EventManager() {
|
|||
// get the information for the broadcast local-link address
|
||||
// TODO(Faraphel): ip / port as argument ?
|
||||
if(const int error = getaddrinfo(
|
||||
"0.0.0.0", // TODO: ff02::1
|
||||
"ff02::1",
|
||||
"5650",
|
||||
&addressHints,
|
||||
&context.broadcastAddressInfo
|
||||
|
@ -105,7 +105,7 @@ void EventManager::loopSender() {
|
|||
// get the information for the broadcast local-link address
|
||||
// TODO(Faraphel): ip / port as argument ?
|
||||
if(const int error = getaddrinfo(
|
||||
"localhost", // TODO: ff02::1
|
||||
"ff02::1",
|
||||
"5650",
|
||||
&addressHints,
|
||||
&destinationInfo
|
||||
|
@ -148,7 +148,7 @@ void EventManager::loopReceiver() {
|
|||
// TODO(Faraphel): port as argument
|
||||
addrinfo* senderInfo;
|
||||
if(getaddrinfo(
|
||||
"0.0.0.0", // hostname
|
||||
"ff02::1", // hostname
|
||||
"5650", // port
|
||||
&addressHints,
|
||||
&senderInfo
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
#include <iostream>
|
||||
#include <numeric>
|
||||
#include <thread>
|
||||
#include <bits/ranges_util.h>
|
||||
#include <pstl/glue_numeric_defs.h>
|
||||
#include <algorithm>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "../../Context.hpp"
|
||||
|
@ -43,9 +42,8 @@ void UndefinedTask::handle(Context& context) {
|
|||
// TODO(Faraphel): should use the machine with the lowest average ping
|
||||
if (context.me.serverEnabled) {
|
||||
// find the remote peer with the highest id that can be a server
|
||||
const auto serverCandidate = std::max_element(
|
||||
context.remotePeers.begin(),
|
||||
context.remotePeers.end(),
|
||||
const auto serverCandidate = std::ranges::max_element(
|
||||
context.remotePeers,
|
||||
[&](auto& remotePeer1, auto& remotePeer2) {
|
||||
return (
|
||||
(remotePeer1.second->information.serverEnabled ? remotePeer1.first : 0) <
|
||||
|
|
Loading…
Reference in a new issue