Files
jak-project/goalc/compiler/nrepl/ReplServer.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

31 lines
629 B
C++

#pragma once
#include "common/cross_sockets/XSocketServer.h"
#include "goalc/compiler/Compiler.h"
enum ReplServerMessageType { PING = 0, EVAL = 10, SHUTDOWN = 20 };
struct ReplServerHeader {
u32 length;
u32 type;
};
class ReplServer : public XSocketServer {
public:
using XSocketServer::XSocketServer;
virtual ~ReplServer();
void post_init() override;
std::optional<std::string> get_msg();
private:
int max_clients = 50;
std::vector<char> header_buffer = std::vector<char>((int)sizeof(ReplServerHeader));
fd_set read_sockets;
std::set<int> client_sockets = {};
void ping_response(int socket);
};