aboutsummaryrefslogtreecommitdiff
path: root/jsonrpc
diff options
context:
space:
mode:
Diffstat (limited to 'jsonrpc')
-rw-r--r--jsonrpc/examples/pubsub_client.rs3
-rw-r--r--jsonrpc/src/client/subscriptions.rs4
-rw-r--r--jsonrpc/src/server/mod.rs6
3 files changed, 7 insertions, 6 deletions
diff --git a/jsonrpc/examples/pubsub_client.rs b/jsonrpc/examples/pubsub_client.rs
index bbfd9b4..823089d 100644
--- a/jsonrpc/examples/pubsub_client.rs
+++ b/jsonrpc/examples/pubsub_client.rs
@@ -16,7 +16,6 @@ async fn run_client() {
.await
.expect("Build a client");
- let clientc = client.clone();
smol::spawn(async move {}).detach();
let sub = client
@@ -34,7 +33,7 @@ async fn run_client() {
loop {
Timer::after(Duration::from_millis(500)).await;
- let _: Pong = clientc
+ let _: Pong = client
.call("Calc.ping", ())
.await
.expect("Send ping request");
diff --git a/jsonrpc/src/client/subscriptions.rs b/jsonrpc/src/client/subscriptions.rs
index fe66f96..3583b33 100644
--- a/jsonrpc/src/client/subscriptions.rs
+++ b/jsonrpc/src/client/subscriptions.rs
@@ -78,7 +78,9 @@ impl Subscriptions {
/// Unsubscribe from the provided subscription id.
pub(super) async fn unsubscribe(&self, id: &SubscriptionID) {
- self.subs.lock().await.remove(id);
+ if let Some(sub) = self.subs.lock().await.remove(id) {
+ sub.close();
+ }
}
/// Notifies the subscription about the given notification.
diff --git a/jsonrpc/src/server/mod.rs b/jsonrpc/src/server/mod.rs
index ddebeb9..bde351e 100644
--- a/jsonrpc/src/server/mod.rs
+++ b/jsonrpc/src/server/mod.rs
@@ -83,11 +83,11 @@ impl Server {
match selfc.listener.accept().await {
Ok(conn) => {
if let Err(err) = selfc.handle_conn(conn).await {
- error!("Failed to handle a new conn: {err}")
+ error!("Handle a new connection: {err}")
}
}
Err(err) => {
- error!("Failed to accept a new conn: {err}")
+ error!("Accept a new connection: {err}")
}
}
}
@@ -249,7 +249,7 @@ impl Server {
trace!("--> new request {msg}");
let on_complete = |result: TaskResult<Result<()>>| async move {
if let TaskResult::Completed(Err(err)) = result {
- error!("Failed to handle a request: {err}");
+ error!("Handle a new request: {err}");
}
};
let selfc = self.clone();