feat: defining server interface

This commit is contained in:
Sara Gerretsen 2025-10-08 17:55:20 +02:00
parent b1659108e3
commit ce2b4e7c7b
3 changed files with 49 additions and 1 deletions

View file

@ -0,0 +1,16 @@
#ifndef YDI_NETWORKING_H
#define YDI_NETWORKING_H
namespace ydi {
enum MessageType {
NONE = 0u,
CONNECTION_REQUEST = 1u,
CONNECTION_RESPONSE = 2u,
};
enum ClueID {
FIRST_CLUE,
};
}
#endif // !YDI_NETWORKING_H

View file

@ -0,0 +1,20 @@
#include "ydi_server.h"
#include <mutex>
#include <optional>
#include <thread>
#include <zmq.hpp>
#include <zmq_addon.hpp>
namespace ydi::server {
struct Service {
std::optional<zmq::context_t> context{ std::nullopt };
std::optional<zmq::socket_t> socket{ std::nullopt };
std::recursive_mutex mtx{};
};
std::optional<Service> service{ std::nullopt };
thread_local std::optional<std::thread> receiveThread{ std::nullopt };
void open(int port) {
}
}

View file

@ -1,10 +1,22 @@
#ifndef YDI_SERVER_H
#define YDI_SERVER_H
#include <string>
#include <cassert>
#include <core/io/image.h>
#include <string/ustring.h>
#include <templates/vector.h>
#include "ydi_networking.h"
namespace ydi::server {
void open(int port);
void close();
namespace receive {
bool isRevealed(ClueID id);
Ref<Image> clueImage(ClueID id);
}
namespace send {
void announceConclusion(ClueID method, ClueID motive, ClueID murderer);
}
}
#endif // !YDI_SERVER_H