Skip to main content

call_over_ws/
call_over_ws.rs

1use holochain_client_core::{
2	connect_ws, Future,
3};
4use serde_json::json;
5use url::Url;
6
7fn main() {
8	let client_url = Url::parse("ws://localhost:3401").expect("valid URL");
9	let fut = connect_ws(&client_url)
10	.and_then(|client| { // connect returns a future
11		client.call( // calling a function also returns a future
12	        "basic-chat".into(),
13	        "chat".into(),
14	        "register".into(),
15	        json!({"name": "Ferris", "avatar_url": ""}),
16    	)
17	}).map(|result| {
18		println!("success: {}", result)
19	}).map_err(|err| {
20		println!("error: {}", err)
21	});
22	tokio::run(fut);
23}