1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:57:35 +00:00

Lagom: Move this into Meta/

This is more of a meta thing, since it's not seeing active development,
but is just a way for me to build some Serenity parts and include them
in other projects. Move it out of the root to keep things tidy.
This commit is contained in:
Andreas Kling 2019-11-18 09:07:05 +01:00
parent 618aebdd8a
commit dcd10149fe
7 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,40 @@
#include <LibCore/CEventLoop.h>
#include <LibCore/CTimer.h>
#include <LibCore/CoreIPCServer.h>
#include <LibCore/CLocalServer.h>
#include <stdio.h>
#include "SimpleEndpoint.h"
class SimpleIPCServer final :
public IPC::Server::ConnectionNG<SimpleEndpoint>,
public SimpleEndpoint {
C_OBJECT(SimpleIPCServer)
public:
SimpleIPCServer(CLocalSocket& socket, int client_id)
: ConnectionNG(*this, socket, client_id)
{
}
virtual OwnPtr<Simple::ComputeSumResponse> handle(const Simple::ComputeSum& message)
{
return make<Simple::ComputeSumResponse>(message.a() + message.b() + message.c());
}
};
int main(int, char**)
{
CEventLoop event_loop;
unlink("/tmp/simple-ipc");
auto server = CLocalServer::construct();
server->listen("/tmp/simple-ipc");
server->on_ready_to_accept = [&] {
auto client_socket = server->accept();
ASSERT(client_socket);
static int next_client_id = 0;
IPC::Server::new_connection_ng_for_client<SimpleIPCServer>(*client_socket, ++next_client_id);
};
return event_loop.exec();
}