what about the wayland parts? is it ok to have the wayland parts in the same file?
what about the wayland parts? is it ok to have the wayland parts in the same file?
eventLoop nowIf the connection cannot be established immediately and O_NONBLOCK is set for the file descriptor for the socket, connect() shall fail and set errno to [EINPROGRESS], but the connection request shall not be aborted, and the connection shall be established asynchronously. Subsequent calls to connect() for the same socket, before the connection is established, shall fail and set errno to [EALREADY].
When the connection has been established asynchronously, select() and poll() shall indicate that the file descriptor for the socket is ready for writing.

eventLoop#include "eventloop.hpp"
#include "../nodetypes/drawable/drawable.hpp"
#include "scenegraphpropagation.hpp"
#include <memory>
#include <mutex>
#include <vector>
namespace StardustXRServer {
EventLoop::EventLoop() :
eventThread(&EventLoop::eventLoop, this) {}
EventLoop::~EventLoop() {
eventThread.join();
}
void EventLoop::callClientsDebug() {
for(auto &client : clients) {
client->scenegraphPropagate("", ScenegraphDebugFunction);
}
}
void EventLoop::eventLoop() {
}
}void EventLoop::eventLoop() {
while(running) {
int socketAcceptFD = socketHandler.acceptNewClient();
if(socketAcceptFD != -1) {
addClient(socketAcceptFD);
} else if(errno != EAGAIN && errno != EWOULDBLOCK) {
running = false;
return;
}
if(poll(pollFDs.data(), pollFDs.size(), 10) <= 0) continue;
std::vector<pollfd> pollFDs = this->pollFDs;
for(pollfd &pollFD : pollFDs) {
auto clientIter = std::find_if(clients.begin(), clients.end(), [pollFD](std::unique_ptr<Client> &client) {
return client->fd == pollFD.fd;
});
if(clientIter == clients.end()) {
//Non-stardust client with fd in clientPollFDs like wayland for example
continue;
}
if(pollFD.revents &= POLLERR | POLLHUP | POLLNVAL) {
removeClient(pollFD.fd);
continue;
}
if(pollFD.revents &= POLLIN) {
Client *const client = clientIter->get();
client->messenger.dispatch();
}
}
}
}