From 0992071a7f1a36424bcfaf1fbc84541ea041df1a Mon Sep 17 00:00:00 2001 From: hozan23 Date: Thu, 11 Apr 2024 10:19:20 +0200 Subject: add support for tokio & improve net crate api --- jsonrpc/examples/client.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'jsonrpc/examples/client.rs') diff --git a/jsonrpc/examples/client.rs b/jsonrpc/examples/client.rs index 2c8cf83..3289772 100644 --- a/jsonrpc/examples/client.rs +++ b/jsonrpc/examples/client.rs @@ -1,7 +1,6 @@ use serde::{Deserialize, Serialize}; -use smol::net::TcpStream; -use karyon_jsonrpc::{Client, ClientConfig}; +use karyon_jsonrpc::Client; #[derive(Deserialize, Serialize)] struct Req { @@ -15,9 +14,11 @@ struct Pong {} fn main() { env_logger::init(); smol::future::block_on(async { - let conn = TcpStream::connect("127.0.0.1:60000").await.unwrap(); - let config = ClientConfig::default(); - let client = Client::new(conn, config); + let client = Client::builder("tcp://127.0.0.1:6000") + .expect("Create client builder") + .build() + .await + .unwrap(); let params = Req { x: 10, y: 7 }; let result: u32 = client.call("Calc.add", params).await.unwrap(); -- cgit v1.2.3