| 97 | } |
| 98 | |
| 99 | pub async fn subscribe_all<F>(&self, callback: F) -> u64 |
| 100 | where |
| 101 | F: Fn(&str, serde_json::Value) + Send + Sync + 'static, |
| 102 | { |
| 103 | let id = { |
| 104 | let mut next = self.next_id.write().await; |
| 105 | *next += 1; |
| 106 | *next |
| 107 | }; |
| 108 | |
| 109 | let mut wildcard = self.wildcard_subscribers.write().await; |
| 110 | wildcard.push(Subscription { |
| 111 | id, |
| 112 | callback: Box::new(callback), |
| 113 | }); |
| 114 | |
| 115 | id |
| 116 | } |
| 117 | |
| 118 | pub async fn unsubscribe_all(&self, id: u64) { |
| 119 | let mut wildcard = self.wildcard_subscribers.write().await; |