#pragma once #include #include #include #include #include "typedefs.hpp" namespace network { class Server; class Connection; class ReadableConnection; class Network; } namespace dv { class value; } class Engine; namespace devtools { class ClientConnection { public: ClientConnection(network::Network& network, u64id_t connection) : network(network), connection(connection) { } ~ClientConnection(); std::string read(); void send(const dv::value& message); void sendResponse(const std::string& type); private: network::Network& network; size_t messageLength = 0; u64id_t connection; }; enum class DebuggingEventType { SET_BREAKPOINT = 1, REMOVE_BREAKPOINT, STEP, STEP_INTO_FUNCTION, RESUME, GET_VALUE, }; struct BreakpointEventDto { std::string source; int line; }; struct SignalEventDto { }; using ValuePath = std::vector>; struct GetValueEventDto { int frame; int localIndex; ValuePath path; }; struct DebuggingEvent { DebuggingEventType type; std::variant data; }; class DebuggingServer { public: DebuggingServer(Engine& engine, const std::string& serverString); ~DebuggingServer(); bool update(); void onHitBreakpoint(dv::value&& stackTrace); void pause(); void sendValue(dv::value&& value, int frame, int local, ValuePath&& path); void setClient(u64id_t client); std::vector pullEvents(); private: Engine& engine; network::Server& server; std::unique_ptr connection; std::vector breakpointEvents; bool performCommand( const std::string& type, const dv::value& map ); }; }