From 1c27f751c30196e2c421ae420dacbc4ff25f0fc7 Mon Sep 17 00:00:00 2001 From: hozan23 Date: Thu, 13 Jun 2024 05:52:48 +0200 Subject: jsonrpc: spread out comments and clean up --- jsonrpc/examples/tokio_server/src/main.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'jsonrpc/examples/tokio_server/src') diff --git a/jsonrpc/examples/tokio_server/src/main.rs b/jsonrpc/examples/tokio_server/src/main.rs index 3bb4871..0a47fda 100644 --- a/jsonrpc/examples/tokio_server/src/main.rs +++ b/jsonrpc/examples/tokio_server/src/main.rs @@ -3,9 +3,7 @@ use std::{sync::Arc, time::Duration}; use serde::{Deserialize, Serialize}; use serde_json::Value; -use karyon_jsonrpc::{ - message::SubscriptionID, rpc_impl, rpc_pubsub_impl, ArcChannel, Error, Server, -}; +use karyon_jsonrpc::{message::SubscriptionID, rpc_impl, rpc_pubsub_impl, Channel, Error, Server}; struct Calc { version: String, @@ -45,16 +43,16 @@ impl Calc { impl Calc { async fn log_subscribe( &self, - chan: ArcChannel, + chan: Arc, method: String, _params: Value, ) -> Result { let sub = chan.new_subscription(&method).await; - let sub_id = sub.id.clone(); + let sub_id = sub.id; tokio::spawn(async move { loop { tokio::time::sleep(std::time::Duration::from_secs(1)).await; - if let Err(_) = sub.notify(serde_json::json!("Hello")).await { + if sub.notify(serde_json::json!("Hello")).await.is_err() { break; } } @@ -65,7 +63,7 @@ impl Calc { async fn log_unsubscribe( &self, - chan: ArcChannel, + chan: Arc, _method: String, params: Value, ) -> Result { -- cgit v1.2.3