summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-09-11 21:19:23 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-09-11 21:19:23 +0200
commitf89944e804e185a7f3308a17a45283fe5d2fb66e (patch)
tree1d1c647aa6255c2179e9646d4ce3537220081b67 /Userland
parent38b75d2a97a8904d429818b18806faa2273ec92e (diff)
downloadserenity-f89944e804e185a7f3308a17a45283fe5d2fb66e.zip
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. :^)
Diffstat (limited to 'Userland')
-rw-r--r--Userland/rpcdump.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/Userland/rpcdump.cpp b/Userland/rpcdump.cpp
index 3e2cdd8b87..59a83ec6e9 100644
--- a/Userland/rpcdump.cpp
+++ b/Userland/rpcdump.cpp
@@ -1,3 +1,5 @@
+#include <AK/JsonObject.h>
+#include <AK/JsonValue.h>
#include <LibCore/CEventLoop.h>
#include <LibCore/CLocalSocket.h>
#include <stdio.h>
@@ -18,6 +20,13 @@ int main(int argc, char** argv)
socket.on_connected = [&] {
dbg() << "Connected to PID " << pid;
+
+ JsonObject request;
+ request.set("type", "GetAllObjects");
+ auto serialized = request.to_string();
+ i32 length = serialized.length();
+ socket.write((const u8*)&length, sizeof(length));
+ socket.write(serialized);
};
socket.on_ready_to_read = [&] {
@@ -32,6 +41,8 @@ int main(int argc, char** argv)
for (int i = 0; i < data.size(); ++i)
putchar(data[i]);
printf("\n");
+
+ loop.quit(0);
};
auto success = socket.connect(CSocketAddress::local(String::format("/tmp/rpc.%d", pid)));