Building a Remote Server

By building a remote server, you can delegate the communication process with AUTD to the server.

Setup

To run a remote server, you need to install Rust.

Next, create a new Rust project with the following commands:

cargo new autd_remote_server
cd autd_remote_server

Next, add the autd3-link-remote crate and tokio as an asynchronous runtime.

cargo add autd3-link-remote --features server
cargo add tokio --features full

Next, add an appropriate Link. Here, for the sake of explanation, we use the dummy Nop link from the autd3 crate.

cargo add autd3 --features link-nop

Next, edit src/main.rs as follows.

In the first argument of RemoteServer::new, specify the port number to use, and in the second argument, specify the Link to use.

use autd3_link_remote::RemoteServer;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    RemoteServer::new(8080, autd3::link::Nop::new())
        .with_graceful_shutdown(async { tokio::signal::ctrl_c().await.unwrap() })
        .run()
        .await?;

    Ok(())
}

After that, you just need to connect to the server using the Remote link on the client side.