user_run_local_task/
user_run_local_task.rs

1use colink::{decode_jwt_without_validation, CoLink, Participant};
2use std::env;
3
4#[tokio::main]
5async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
6    let args = env::args().skip(1).collect::<Vec<_>>();
7    let addr = &args[0];
8    let jwt_a = &args[1];
9    let msg = if args.len() > 2 { &args[2] } else { "hello" };
10    let user_id_a = decode_jwt_without_validation(jwt_a).unwrap().user_id;
11
12    let participants = vec![Participant {
13        user_id: user_id_a.to_string(),
14        role: "initiator".to_string(),
15    }];
16    let cl = CoLink::new(addr, jwt_a);
17    let task_id = cl
18        .run_task("greetings", msg.as_bytes(), &participants, false)
19        .await?;
20    println!(
21        "Local task {} has been created, it will remain in started status until the protocol starts.",
22        task_id
23    );
24
25    Ok(())
26}