feat: defining server interface
This commit is contained in:
parent
b1659108e3
commit
ce2b4e7c7b
3 changed files with 49 additions and 1 deletions
16
modules/you_done_it/ydi_networking.h
Normal file
16
modules/you_done_it/ydi_networking.h
Normal 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
|
||||
20
modules/you_done_it/ydi_server.cpp
Normal file
20
modules/you_done_it/ydi_server.cpp
Normal 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) {
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue