aboutsummaryrefslogtreecommitdiff
path: root/jsonrpc/examples
diff options
context:
space:
mode:
Diffstat (limited to 'jsonrpc/examples')
-rw-r--r--jsonrpc/examples/client.rs5
-rw-r--r--jsonrpc/examples/server.rs7
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);