diff options
Diffstat (limited to 'jsonrpc/examples')
-rw-r--r-- | jsonrpc/examples/client.rs | 5 | ||||
-rw-r--r-- | jsonrpc/examples/server.rs | 7 |
2 files changed, 6 insertions, 6 deletions
diff --git a/jsonrpc/examples/client.rs b/jsonrpc/examples/client.rs index 6b60233..8f46a8e 100644 --- a/jsonrpc/examples/client.rs +++ b/jsonrpc/examples/client.rs @@ -1,4 +1,5 @@ use serde::{Deserialize, Serialize}; +use smol::net::TcpStream; use karyons_jsonrpc::{Client, ClientConfig}; @@ -14,9 +15,9 @@ struct Pong {} fn main() { env_logger::init(); smol::future::block_on(async { - let endpoint = "tcp://127.0.0.1:60000".parse().unwrap(); + let conn = TcpStream::connect("127.0.0.1:60000").await.unwrap(); let config = ClientConfig::default(); - let client = Client::new_with_endpoint(&endpoint, config).await.unwrap(); + let client = Client::new(conn.into(), config); let params = Req { x: 10, y: 7 }; let result: u32 = client.call("Calc.add", params).await.unwrap(); diff --git a/jsonrpc/examples/server.rs b/jsonrpc/examples/server.rs index 512913a..4109e0d 100644 --- a/jsonrpc/examples/server.rs +++ b/jsonrpc/examples/server.rs @@ -2,6 +2,7 @@ use std::sync::Arc; use serde::{Deserialize, Serialize}; use serde_json::Value; +use smol::net::TcpListener; use karyons_jsonrpc::{register_service, JsonRPCError, Server, ServerConfig}; @@ -43,11 +44,9 @@ fn main() { let ex = Arc::new(smol::Executor::new()); smol::block_on(ex.clone().run(async { // Creates a new server - let endpoint = "tcp://127.0.0.1:60000".parse().unwrap(); + let listener = TcpListener::bind("127.0.0.1:60000").await.unwrap(); let config = ServerConfig::default(); - let server = Server::new_with_endpoint(&endpoint, config, ex) - .await - .unwrap(); + let server = Server::new(listener.into(), config, ex); // Register the Calc service register_service!(Calc, ping, add, sub, version); |