| author | Stephen Paul Weber
<singpolyma@singpolyma.net> 2026-03-11 18:15:24 UTC |
| committer | Stephen Paul Weber
<singpolyma@singpolyma.net> 2026-03-11 18:16:40 UTC |
| parent | 6b9d41215411408382545b08f1963090632ebc30 |
| README.md | +10 | -18 |
| borogove/Outbox.hx | +1 | -1 |
| docs/c/index.md | +13 | -12 |
| docs/js/index.md | +9 | -14 |
diff --git a/README.md b/README.md index ed79798..b11292c 100644 --- a/README.md +++ b/README.md @@ -2,21 +2,7 @@ Working towards simplicity in developing Snikket-compatible apps. - haxelib git jsImport https://github.com/back2dos/jsImport - haxelib install datetime - haxelib install haxe-strings - haxelib install hsluv - haxelib install tink_http - haxelib install sha - haxelib install thenshim - haxelib install HtmlParser - haxelib install hxnodejs - haxelib git hxtsdgen https://github.com/singpolyma/hxtsdgen - haxelib install utest - haxelib git hxcpp https://github.com/singpolyma/hxcpp update-sqlite - cd ~/haxe/hxcpp/git/tools/hxcpp - haxe compile.hxml - cd - + make hx-build-dep make # JavaScript / TypeScript @@ -29,11 +15,17 @@ Also Typescript typings are generated which include documenation comments. # C -`libborogove.so` and `cpp/borogove.h`, the latter has documentation comments +`libborogove.so` and `cpp/borogove.h`, the latter has documentation comments. -## Alpine Linux +Alternately there is also `libborogove.batteriesincluded.so` which vendors some dependencies. Or `libborogove.a` which is a static library. -See [borogove-sdk build recipe](https://pkgs.alpinelinux.org/package/edge/testing/x86_64/borogove-sdk) +If you want to build on a system that does not have haxe: + + make cpp + +The the `cpp` folder will contain C++ code and a Makefile with no haxe dependency. + +[Alpine package](https://pkgs.alpinelinux.org/package/edge/community/x86/borogove-sdk) # Swift diff --git a/borogove/Outbox.hx b/borogove/Outbox.hx index 3a9d415..edfde46 100644 --- a/borogove/Outbox.hx +++ b/borogove/Outbox.hx @@ -1,7 +1,7 @@ package borogove; class Outbox { - private final items = []; + private final items: Array<OutboxItem> = []; private var paused = true; public function new() { } diff --git a/docs/c/index.md b/docs/c/index.md index 48a7e59..e6ced19 100644 --- a/docs/c/index.md +++ b/docs/c/index.md @@ -44,31 +44,32 @@ Let’s continue by starting your first chat. A chat contains messages, a list o ```c void *chat = NULL; +void *available_chats_iterator = NULL; // This will run on a background thread -bool available_chats(const char *q, void **chats, size_t cchats, void *client) { - // You can check if q is the search we expect +bool available_chats(void *achat, void *client) { + // You can check if borogove_available_chat_iterator_q is the search we expect // Allows running searches in parallel as a user types - chat = borogove_client_start_chat(client, chats[0]); + if (achat) { + chat = borogove_client_start_chat(client, chat); - // Don't forget to release your memory - for (size_t i = 0; i < cchats; i++) { - borogove_release(chats[i]); + // Don't forget to release your memory + borogove_release(achat); } - borogove_release(chats); - borogove_release(q); - // Stop searching - return true; + // Call next again, or stop searching + borogove_release(available_chats_iterator); + available_chats_iterator = NULL; } // And in main... -borogove_client_find_available_chats(client, "hatter@example.com", available_chats, client); +avilable_chats_iterator = borogove_client_find_available_chats(client, "hatter@example.com"); +borogove_available_chat_iterator_next(available_chats_iterator, available_chats, client); ``` -`borogove_client_find_available_chats` will call the callback with all results found so far, and keep searching until either it has exhausted all options or the callback returns `true`. Here we just store in a global the first chat that was found, as simple example. +`borogove_client_find_available_chats` will return an iterator that can be stepped asynchronously with a callback. Here we just store in a global the first chat that was found, as a simple example. You can always search by the full ID or URI of any chat on the network. Locally known chats will also be returned, as well as any chats from other services configured on the account. diff --git a/docs/js/index.md b/docs/js/index.md index b24d6f7..a5d7f18 100644 --- a/docs/js/index.md +++ b/docs/js/index.md @@ -42,22 +42,17 @@ In real life you probably want to prompt the user when receiving the event. You Let’s continue by starting your first chat. A chat contains messages, a list of people that are participating, and optionally a list of members. The example below shows how to start a chat with a new contact: ```typescript -const chat = await new Promise(resolve => { - const search = "hatter@example.com"; - client.findAvailableChats(search, (q, availableChats) => { - // Check if the results are for our search - // Allows running searches in parallel as a user types - if (search !== q) return; - - resolve(client.startChat(availableChats[0])); - - // Stop searching - return true; - }); -}); +async function findOneChat(client: borogove.Client): borogove.Chat { + const iterator = client.findAvailableChats("hatter@example.com"); + for await (const availableChat of iterator) { + return client.startChat(availableChat); + } + + return null; +} ``` -[`findAvailableChats`](./borogove.client.findavailablechats.md) will call the callback with all results found so far, and keep searching until either it has exhausted all options or the callback returns `true`. Here we just create a promise to resolve to the first chat that is found. +[`findAvailableChats`](./borogove.client.findavailablechats.md) return an async iterator over all the search results. Here we return the first one that is found. You can always search by the full ID or URI of any chat on the network. Locally known chats will also be returned, as well as any chats from other services configured on the account.