summaryrefslogtreecommitdiff
path: root/Lagom/SimpleIPCClient.cpp
blob: 031cccf88d3bc1127f3ec12a7dc9b5a69e84a933 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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();
}