Files
jak-project/game/system/Deci2Server.h
T
Tyler Wilding 7b6d732a77 goalc: Add TCP server socket in REPL process (#1335)
* goalc: cleanup goalc's main method and add nrepl listener socket

* deps: add standalone ASIO for sockets

* lint: formatting

* common: make a common interface for creating a server socket

* goalc: setup new repl server

* deps: remove asio

* goalc: debug issues, nrepl is working again

* git: rename files

* attempt to fix linux function call

* test

* scripts: make the error message even more obvious....

* goalc: make suggested changes, still can't reconnect properly

* game: pull out single-client logic from XSocketServer

* nrepl: supports multiple clients and disconnection/reconnects

* goalc: some minor fixes for tests

* goalc: save repl history when the compiler reloads

* common: add include for linux networking

* a few small changes to fix tests

* is it the assert?

* change thread start order and add a print to an assert

Co-authored-by: water <awaterford111445@gmail.com>
2022-05-06 18:19:37 -04:00

45 lines
992 B
C++

#pragma once
#include "common/cross_sockets/XSocketServer.h"
#include "deci_common.h"
#include <condition_variable>
/// @brief Basic implementation of a DECI2 server.
/// Works with deci2.cpp(sceDeci2) to implement the networking on target
class Deci2Server : public XSocketServer {
public:
using XSocketServer::XSocketServer;
virtual ~Deci2Server();
void post_init() override;
void read_data();
void send_data(void* buf, u16 len);
bool is_client_connected();
void wait_for_protos_ready();
void send_proto_ready(Deci2Driver* drivers, int* driver_count);
void lock();
void unlock();
protected:
void accept_thread_func();
private:
bool protocols_ready = false;
std::condition_variable cv;
Deci2Driver* d2_drivers = nullptr;
int* d2_driver_count = nullptr;
int accepted_socket = -1;
bool kill_accept_thread = false;
bool accept_thread_running = false;
std::thread accept_thread;
std::mutex server_mutex;
bool client_connected = false;
};