mirror of
https://github.com/open-goal/jak-project
synced 2026-05-23 15:02:01 -04:00
eb703ee96e
Motivated by - https://github.com/open-goal/opengoal-vscode/pull/358 This addresses the following: - Fixes #2939 spam edge-case - Stop picking a different nREPL port based on the game mode by default, this causes friction for tools in the average usecase (having a REPL open for a single game, and wanting to connect to it). `goalc` spins up fine even if the port is already bound to. - For people that need/want this behaviour, adding per-game configuration to the `repl-config.json` is on my todo list. - Allows `goalc` to permit redefining symbols, including functions. This is defaulted to off via the `repl-config.json` but it allows you to for example, change the definition of a function without having to restart and rebuild the entire game.  - Updates the welcome message to include a bunch of useful metadata up-front. Cleaned up all the startup logs that appear when starting goalc, many of whom's information is now included in the welcome message. - Before:  - After: 
33 lines
688 B
C++
33 lines
688 B
C++
#pragma once
|
|
|
|
#include <optional>
|
|
#include <set>
|
|
|
|
#include "common/cross_sockets/XSocketServer.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 error_response(int socket, const std::string& error);
|
|
void ping_response(int socket);
|
|
};
|