|
@@ -20,8 +20,8 @@ use url::Url;
|
|
|
#[derive(Debug)]
|
|
|
pub struct Pool {
|
|
|
clients: HashMap<Url, Client>,
|
|
|
- sender: mpsc::Sender<(Event, Url)>,
|
|
|
- receiver: mpsc::Receiver<(Event, Url)>,
|
|
|
+ sender: mpsc::Sender<(Response, Url)>,
|
|
|
+ receiver: mpsc::Receiver<(Response, Url)>,
|
|
|
subscriptions: HashMap<SubscriptionId, Vec<ActiveSubscription>>,
|
|
|
}
|
|
|
|
|
@@ -31,18 +31,6 @@ impl Default for Pool {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-/// Client event
|
|
|
-///
|
|
|
-/// This type wraps a response a disconnected event. The disconnected will be
|
|
|
-/// the last event to be sent.
|
|
|
-#[derive(Debug, Clone)]
|
|
|
-pub enum Event {
|
|
|
- /// A response
|
|
|
- Response(Box<Response>),
|
|
|
- /// A disconnection event
|
|
|
- Disconnected,
|
|
|
-}
|
|
|
-
|
|
|
const DEFAULT_CHANNEL_BUFFER_SIZE: usize = 10_000;
|
|
|
|
|
|
impl Pool {
|
|
@@ -58,12 +46,12 @@ impl Pool {
|
|
|
}
|
|
|
|
|
|
/// Tries to receive a message from any of the connected relayers
|
|
|
- pub fn try_recv(&mut self) -> Option<(Event, Url)> {
|
|
|
+ pub fn try_recv(&mut self) -> Option<(Response, Url)> {
|
|
|
self.receiver.try_recv().ok()
|
|
|
}
|
|
|
|
|
|
/// Receives a message from any of the connected relayers
|
|
|
- pub async fn recv(&mut self) -> Option<(Event, Url)> {
|
|
|
+ pub async fn recv(&mut self) -> Option<(Response, Url)> {
|
|
|
self.receiver.recv().await
|
|
|
}
|
|
|
|