aboutsummaryrefslogtreecommitdiff
path: root/jsonrpc/src/server/channel.rs
diff options
context:
space:
mode:
Diffstat (limited to 'jsonrpc/src/server/channel.rs')
-rw-r--r--jsonrpc/src/server/channel.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/jsonrpc/src/server/channel.rs b/jsonrpc/src/server/channel.rs
index efcd344..a9d1002 100644
--- a/jsonrpc/src/server/channel.rs
+++ b/jsonrpc/src/server/channel.rs
@@ -59,7 +59,7 @@ pub struct Channel {
}
impl Channel {
- /// Creates a new `Channel`
+ /// Creates a new [`Channel`]
pub(crate) fn new(chan: async_channel::Sender<NewNotification>) -> ArcChannel {
Arc::new(Self {
chan,
@@ -67,7 +67,7 @@ impl Channel {
})
}
- /// Creates a new subscription
+ /// Creates a new [`Subscription`]
pub async fn new_subscription(self: &Arc<Self>, method: &str) -> Subscription {
let sub_id = random_32();
let sub = Subscription::new(self.clone(), sub_id, self.chan.clone(), method);
@@ -76,7 +76,7 @@ impl Channel {
}
/// Removes a subscription
- pub async fn remove_subscription(self: &Arc<Self>, id: &SubscriptionID) {
+ pub async fn remove_subscription(&self, id: &SubscriptionID) {
let mut subs = self.subs.lock().await;
let i = match subs.iter().position(|i| i == id) {
Some(i) => i,
@@ -84,4 +84,8 @@ impl Channel {
};
subs.remove(i);
}
+
+ pub fn close(&self) {
+ self.chan.close();
+ }
}