| … | … | @@ -22,6 +22,24 @@ encodings the same way, with `schema/build.js` and the resulting |
| 22 | 22 | - **hyperschema-c** — structs + `preencode/encode/decode/destroy(compact_state_t*)` |
| 23 | 23 | - **hrpc-c** — typed sans-io RPC over the bare-rpc wire (unary + event handlers) |
| 24 | 24 | |
| 25 | ## Using it from C++ |
| 26 | |
| 27 | #include "client/client.h" |
| 28 | |
| 29 | swarmd::Client c; |
| 30 | c.on.on_message = [](uint64_t ch, uint64_t slot, uint64_t kind, uint64_t who, |
| 31 | const uint8_t *b, size_t n) { /* ... */ }; |
| 32 | c.connect("/tmp/s.sock", "my-app"); |
| 33 | c.join(topic); |
| 34 | const uint64_t ch = c.open_channel("my-app/v1", {}, 2); |
| 35 | while (running) { |
| 36 | c.send(ch, 0, 0, bytes, len); // false = nobody has it open yet, retry |
| 37 | c.poll(200); |
| 38 | } |
| 39 | |
| 40 | ⛔ Do not write the wire yourself. Two clients in this repo did, and both were |
| 41 | wrong in ways the daemon could not distinguish from a bad daemon. |
| 42 | |
| 25 | 43 | ## Links against |
| 26 | 44 | |
| 27 | 45 | - **libcompact** — compact-encoding in C, ABI-identical to the JS codec |
| … | … | @@ -34,6 +52,7 @@ encodings the same way, with `schema/build.js` and the resulting |
| 34 | 52 | ./test/test_uds_backpressure |
| 35 | 53 | ./test/test_control |
| 36 | 54 | ./test/test_send_truth |
| 55 | ./test/test_client |
| 37 | 56 | |
| 38 | 57 | ## Status |
| 39 | 58 | |
| … | … | @@ -44,7 +63,8 @@ encodings the same way, with `schema/build.js` and the resulting |
| 44 | 63 | daemon UdxTransport + queue + control plane runs |
| 45 | 64 | channels Protomux channel per peer, SEND/on-message D1/D4 PASS |
| 46 | 65 | content liboverlay: hash/serve/fetch/cancel D6 PASS |
| 47 | | tools/ swarmd-probe — the smallest real client |
| 66 | client/ swarmd::Client — the ONE wire implementation 28/28 |
| 67 | tools/ swarmd-probe — built on it, in 181 lines |
| 48 | 68 | |
| 49 | 69 | ./swarmd --socket /tmp/s.sock --storage ~/.swarmd # public DHT |
| 50 | 70 | [swarmd] listening on /tmp/s.sock |