summaryrefslogtreecommitdiffstats
path: root/lib/sender.h
diff options
context:
space:
mode:
authorJulian Bouzas <julian.bouzas@collabora.com>2021-04-20 04:08:58 -0400
committerGeorge Kiagiadakis <george.kiagiadakis@collabora.com>2021-07-28 13:19:02 +0300
commitf25bb13718f334bc0c96d29ea9f3a57c0a6f3a34 (patch)
treeeaa30eafe2df92e3d5d75571d022c3a775246bff /lib/sender.h
parent7bf96bda703dd157385cbb175ec90bd6f38af404 (diff)
lib: add wpipc library
Simple library that uses sockets for inter-process communication. It provides an API to create server and client objects. Users can add custom handlers in the server, and clients can send requests for those custom handlers. Signed-off-by: George Kiagiadakis <george.kiagiadakis@collabora.com>
Diffstat (limited to 'lib/sender.h')
-rw-r--r--lib/sender.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/lib/sender.h b/lib/sender.h
new file mode 100644
index 0000000..88aaf3a
--- /dev/null
+++ b/lib/sender.h
@@ -0,0 +1,75 @@
+/* PipeWire AGL Cluster IPC
+ *
+ * Copyright © 2021 Collabora Ltd.
+ * @author Julian Bouzas <julian.bouzas@collabora.com>
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#ifndef __ICIPC_SENDER_H__
+#define __ICIPC_SENDER_H__
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <stddef.h>
+
+#include "defs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct icipc_sender;
+
+typedef void (*icipc_sender_lost_conn_func_t) (struct icipc_sender *self,
+ int receiver_fd,
+ void *data);
+
+typedef void (*icipc_sender_reply_func_t) (struct icipc_sender *self,
+ const uint8_t *buffer,
+ size_t size,
+ void *data);
+
+ICIPC_API
+struct icipc_sender *
+icipc_sender_new (const char *path,
+ size_t buffer_size,
+ icipc_sender_lost_conn_func_t lost_func,
+ void *lost_data,
+ size_t user_size);
+
+ICIPC_API
+void
+icipc_sender_free (struct icipc_sender *self);
+
+ICIPC_API
+bool
+icipc_sender_connect (struct icipc_sender *self);
+
+ICIPC_API
+void
+icipc_sender_disconnect (struct icipc_sender *self);
+
+ICIPC_API
+bool
+icipc_sender_is_connected (struct icipc_sender *self);
+
+ICIPC_API
+bool
+icipc_sender_send (struct icipc_sender *self,
+ const uint8_t *buffer,
+ size_t size,
+ icipc_sender_reply_func_t reply,
+ void *data);
+
+/* for subclasses only */
+
+ICIPC_API
+void *
+icipc_sender_get_user_data (struct icipc_sender *self);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif