A telnet chat server written in Rust, running on Lunatic.
I wrote a blog post about the implementation,
you can read it here. The implementation has significantly
changed since the blog was written and updated to the new higher-level process architecture in lunatic.
The server is written in Rust. The Rust code is then compiled to WebAssembly and runs on top of Lunatic. Each connection runs in a separate (lightweight) process, has its own state and sends just a diff of esc-sequences back to the terminal to bring it up to date with the current render buffer.
Each rectangle represents a process. The ClientProcess
holds the current render state that can be changed
by new commands coming from telnet or new messages from channels that the client joined. The CoordinatorSup
is a supervisor that will restart the global coordinator if it dies. All processes that depend on the
coordinator are linked to it, if it dies it will disconnect all clients and kill all channels.
If you have rustup installed:
# Add the wasm32-wasi target
> rustup target add wasm32-wasi
# Build the project
> cargo build --target=wasm32-wasi
To run it, you will need to have lunatic on your PATH.
If this is the case you can just run cargo run
or find the generated telnet-chat.wasm
file
in the target folder and run it with lunatic path/to/telnet-chat.wasm
.
MIT