Skip to content

Commit

Permalink
Update documentation on user rpc calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
lPrimemaster committed Feb 10, 2025
1 parent 16b960b commit 8d0815d
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion docs/backends.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,31 @@ void MyBackend::my_rpc(const std::vector<std::uint8_t>& data)
const rpc = MxRpc.Create();
rpc.then((handle) => {
handle.BckCallUserRpc([
MxGenericType.str32('MyBackend::rpc'),
MxGenericType.str32('my_backend'), // Executable name (as listed in home page)
MxGenericType.int32(42, 'generic') // Custom data
]);
});
```

You can also bundle multiple data with the help of the `MxGenericType.makeData` and `MxGenericType.concatData` functions.

```ts
const rpc = MxRpc.Create();
rpc.then((handle) => {

const data = MxGenericType.concatData([
MxGenericType.int8(42),
MxGenericType.f32(3.141592654)
]);

handle.BckCallUserRpc([
MxGenericType.str32('my_backend'), // Executable name (as listed in home page)
MxGenericType.makeData(data, 'generic') // Custom data
]);
});
```
Of course proper data handling must take place at the backend user function.

The plugin containing this code will call the backend user rpc function
as long as it is connected to the mx system.

Expand Down

0 comments on commit 8d0815d

Please sign in to comment.