mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-02-28 22:23:13 +00:00
Examples for liblogosdelivery
This directory contains example programs demonstrating the usage of the Logos Messaging API (LMAPI) library.
Building the Examples
Prerequisites
-
Build the liblogosdelivery library first:
cd /path/to/logos-messaging-nim make liblogosdelivery -
The library will be available in
build/liblogosdelivery.so(or.dylibon macOS,.dllon Windows)
Compile the liblogosdelivery Example
On Linux/macOS:
# Shared library
gcc -o liblogosdelivery_example liblogosdelivery_example.c -I.. -L../../build -llmapi -Wl,-rpath,../../build
# Static library (if built with STATIC=1)
gcc -o liblogosdelivery_example liblogosdelivery_example.c -I.. ../../build/liblogosdelivery.a -lpthread -lm -ldl
On macOS:
gcc -o liblogosdelivery_example liblogosdelivery_example.c -I.. -L../../build -llmapi
On Windows (MinGW):
gcc -o liblogosdelivery_example.exe liblogosdelivery_example.c -I.. -L../../build -llmapi -lws2_32
Running the Examples
liblogosdelivery Example
./liblogosdelivery_example
This example demonstrates:
- Creating a node with configuration
- Starting the node
- Subscribing to a content topic
- Sending a message
- Unsubscribing from the topic
- Stopping and destroying the node
Expected Output
=== Logos Messaging API (LMAPI) Example ===
1. Creating node...
[create_node] Success
2. Starting node...
[start_node] Success
3. Subscribing to content topic...
[subscribe] Success
4. Sending a message...
[send] Success: <request-id>
5. Unsubscribing from content topic...
[unsubscribe] Success
6. Stopping node...
[stop_node] Success
7. Destroying context...
[destroy] Success
=== Example completed ===
Notes
- The examples use simple synchronous callbacks with sleep() for demonstration
- In production code, you should use proper async patterns
- Error handling in these examples is basic - production code should be more robust
- The payload in messages must be base64-encoded