mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-01-24 15:29:59 -05:00
Example usage of matrix-rust-sdk from WASM
This example is a version of the command bot that runs as WASM in your browser instead of natively on your machine.
To run this example, first ensure:
- The wasm-unknown-unknown target is available:
rustup target add wasm32-unknown-unknown. wasm-packis in the path: see instructions here.- A homeserver is available at
http://localhost:8008with a userusernameand passwordwordpass. If this is not the case, you'll want to update these connection settings insrc/lib.rsbefore building.
You can then build the example locally with:
npm install
npm run serve
and then visiting http://localhost:8080 in a browser should run the example!
This example is loosely based off of
this example,
an example usage of fetch from wasm-bindgen.
NOTE: The webpage at http://localhost:8080 will not display anything. It just
runs the bot on the page, printing log messages to the console and responding to
the !party command.