1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:47:35 +00:00

Inspector+LibCore+rpcdump: Rework the RPC stuff to be request/response

RPC clients now send JSON-encoded requests to the RPC server.
The connection also stays alive instead of disconnecting automatically
after the initial CObject graph dump.

JSON payloads are preceded by a single host-order encoded 32-bit int
containing the length of the payload.

So far, we have three RPC commands:

    - Identify
    - GetAllObjects
    - Disconnect

We'll be adding more of these as we go along. :^)
This commit is contained in:
Andreas Kling 2019-09-11 21:19:23 +02:00
parent 38b75d2a97
commit f89944e804
5 changed files with 217 additions and 38 deletions

View file

@ -3,6 +3,10 @@
#include <AK/NonnullOwnPtrVector.h>
#include <LibCore/CLocalSocket.h>
namespace AK {
class JsonObject;
}
class RemoteObjectGraphModel;
class RemoteObject;
@ -11,11 +15,22 @@ public:
explicit RemoteProcess(pid_t);
void update();
pid_t pid() const { return m_pid; }
const String& process_name() const { return m_process_name; }
RemoteObjectGraphModel& object_graph_model() { return *m_object_graph_model; }
const NonnullOwnPtrVector<RemoteObject>& roots() const { return m_roots; }
Function<void()> on_update;
private:
void handle_get_all_objects_response(const AK::JsonObject&);
void handle_identify_response(const AK::JsonObject&);
void send_request(const AK::JsonObject&);
pid_t m_pid { -1 };
String m_process_name;
NonnullRefPtr<RemoteObjectGraphModel> m_object_graph_model;
CLocalSocket m_socket;
NonnullOwnPtrVector<RemoteObject> m_roots;