From 598f9e2d47da80f2bec2ead9c2fe215eff157936 Mon Sep 17 00:00:00 2001 From: hozan23 Date: Mon, 20 Nov 2023 23:15:10 +0300 Subject: jsonrpc: add Codec struct for reading from and writing to the connection --- jsonrpc/examples/client.rs | 5 +++-- jsonrpc/examples/server.rs | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'jsonrpc/examples') 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); -- cgit v1.2.3