diff options
author | hozan23 <hozan23@proton.me> | 2023-11-20 23:15:10 +0300 |
---|---|---|
committer | hozan23 <hozan23@proton.me> | 2023-11-20 23:15:10 +0300 |
commit | 598f9e2d47da80f2bec2ead9c2fe215eff157936 (patch) | |
tree | 121f1a391a01d3b7856d948aaaa3c154317f0cd6 /jsonrpc/examples | |
parent | 2ee34b432e7652a34ee64a706b5ebc1bce867dce (diff) |
jsonrpc: add Codec struct for reading from and writing to the connection
Diffstat (limited to 'jsonrpc/examples')
-rw-r--r-- | jsonrpc/examples/client.rs | 5 | ||||
-rw-r--r-- | jsonrpc/examples/server.rs | 7 |
2 files changed, 8 insertions, 4 deletions
diff --git a/jsonrpc/examples/client.rs b/jsonrpc/examples/client.rs index 0063098..6b60233 100644 --- a/jsonrpc/examples/client.rs +++ b/jsonrpc/examples/client.rs @@ -1,6 +1,6 @@ use serde::{Deserialize, Serialize}; -use karyons_jsonrpc::Client; +use karyons_jsonrpc::{Client, ClientConfig}; #[derive(Deserialize, Serialize)] struct Req { @@ -15,7 +15,8 @@ fn main() { env_logger::init(); smol::future::block_on(async { let endpoint = "tcp://127.0.0.1:60000".parse().unwrap(); - let client = Client::new_with_endpoint(&endpoint, None).await.unwrap(); + let config = ClientConfig::default(); + let client = Client::new_with_endpoint(&endpoint, config).await.unwrap(); 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 367bfe9..512913a 100644 --- a/jsonrpc/examples/server.rs +++ b/jsonrpc/examples/server.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use serde::{Deserialize, Serialize}; use serde_json::Value; -use karyons_jsonrpc::{register_service, JsonRPCError, Server}; +use karyons_jsonrpc::{register_service, JsonRPCError, Server, ServerConfig}; struct Calc { version: String, @@ -44,7 +44,10 @@ fn main() { smol::block_on(ex.clone().run(async { // Creates a new server let endpoint = "tcp://127.0.0.1:60000".parse().unwrap(); - let server = Server::new_with_endpoint(&endpoint, ex).await.unwrap(); + let config = ServerConfig::default(); + let server = Server::new_with_endpoint(&endpoint, config, ex) + .await + .unwrap(); // Register the Calc service register_service!(Calc, ping, add, sub, version); |