mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:17:45 +00:00
Lagom: Add a simple IPC client and server for host-side testing
Add LibIPC to the Lagom build, and also implement two little test apps so we can run IPC tests on other systems.
This commit is contained in:
parent
8e684f0959
commit
0f0b00dc1f
4 changed files with 93 additions and 2 deletions
39
Lagom/SimpleIPCClient.cpp
Normal file
39
Lagom/SimpleIPCClient.cpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
#include <LibCore/CEventLoop.h>
|
||||
#include <LibCore/CTimer.h>
|
||||
#include <LibCore/CoreIPCClient.h>
|
||||
#include <stdio.h>
|
||||
#include "SimpleEndpoint.h"
|
||||
|
||||
class SimpleIPCClient : public IPC::Client::ConnectionNG<SimpleEndpoint> {
|
||||
C_OBJECT(SimpleIPCClient)
|
||||
public:
|
||||
SimpleIPCClient()
|
||||
: ConnectionNG("/tmp/simple-ipc")
|
||||
{}
|
||||
|
||||
virtual void handshake() override {}
|
||||
|
||||
i32 compute_sum(i32 a, i32 b, i32 c)
|
||||
{
|
||||
return send_sync<Simple::ComputeSum>(a, b, c)->sum();
|
||||
}
|
||||
};
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
CEventLoop event_loop;
|
||||
|
||||
SimpleIPCClient client;
|
||||
|
||||
CTimer timer(100, [&] {
|
||||
i32 sum = client.compute_sum(1, 2, 3);
|
||||
dbg() << "Sum: " << sum;
|
||||
});
|
||||
|
||||
CTimer kill_timer(5000, [&] {
|
||||
dbg() << "Timer fired, good-bye! :^)";
|
||||
event_loop.quit(0);
|
||||
});
|
||||
|
||||
return event_loop.exec();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue