Files
jak-project/game/system/Deci2Server.h
T
doctashay c2cb053a5d spdlog implementation (#58)
* Commit new spdlog implementation 

Hopefully resolves Linux build dependency errors

* clang formatting

* Fix Linux-only definition

Found the culprit!

* More Linux fixes

Linus Torvalds have mercy on my soul

* Replace printf logging with spdlog equivalent

Preserve previous printfs in comments for now. Spdlog needs to be configured to be thread-safe. Few additional printfs to convert later. No changes have been made to GOAL's internal printing system

* clang-format stuff

* ugh more clang-format

why

* Another shot

* CMakeLists.txt update

Fix issues related to spdlog version targeting

* Remove old prints + fix log types

Up next is the transition to a git submodule, should be simple enough

* spdlog is now a git submodule

* adapted for project

* Linux fix

* More fixes

Yikes

* Update for linux

I should really fix my WSL environment

* Update workflow.yaml

Hopefully will resolve issues with GitHub Actions on Linux
2020-10-03 09:39:04 -04:00

62 lines
1.4 KiB
C++

#pragma once
/*!
* @file Deci2Server.h
* Basic implementation of a DECI2 server.
* Works with deci2.cpp (sceDeci2) to implement the networking on target
*/
#ifndef JAK1_DECI2SERVER_H
#define JAK1_DECI2SERVER_H
#ifdef __linux
#include <netinet/in.h>
#elif _WIN32
#include <Windows.h>
#endif
#include <thread>
#include <mutex>
#include <condition_variable>
#include <functional>
#include "game/system/deci_common.h"
#include "third-party/spdlog/include/spdlog/spdlog.h"
class Deci2Server {
public:
static constexpr int BUFFER_SIZE = 32 * 1024 * 1024;
Deci2Server(std::function<bool()> shutdown_callback);
~Deci2Server();
bool init();
bool check_for_listener();
void send_data(void* buf, u16 len);
void lock();
void unlock();
void wait_for_protos_ready();
void send_proto_ready(Deci2Driver* drivers, int* driver_count);
void run();
private:
void close_server_socket();
void accept_thread_func();
bool kill_accept_thread = false;
char* buffer = nullptr;
int server_socket = -1;
struct sockaddr_in addr = {};
int new_sock = -1;
bool server_initialized = false;
bool accept_thread_running = false;
bool server_connected = false;
std::function<bool()> want_exit;
std::thread accept_thread;
std::condition_variable cv;
bool protocols_ready = false;
std::mutex deci_mutex;
Deci2Driver* d2_drivers = nullptr;
int* d2_driver_count = nullptr;
};
#endif // JAK1_DECI2SERVER_H