pub struct Messaging { /* private fields */ }Expand description
Connection manager for miner WebSocket sessions.
Each connected miner gets an mpsc::UnboundedSender that the WS task polls.
Implementations§
Source§impl Messaging
impl Messaging
pub fn new() -> Arc<Messaging> ⓘ
Sourcepub async fn register(&self, device_id: String, tx: UnboundedSender<String>)
pub async fn register(&self, device_id: String, tx: UnboundedSender<String>)
Register a connected miner.
Sourcepub async fn unregister(&self, device_id: &str)
pub async fn unregister(&self, device_id: &str)
Remove a disconnected miner.
Sourcepub async fn connected_count(&self) -> usize
pub async fn connected_count(&self) -> usize
Number of currently connected miners.
Sourcepub async fn active_devices(&self) -> Vec<String>
pub async fn active_devices(&self) -> Vec<String>
List all connected device IDs.
Sourcepub async fn broadcast(&self, msg: &ValidatorMessage)
pub async fn broadcast(&self, msg: &ValidatorMessage)
Push a message to every connected miner.
Sourcepub async fn send_to(&self, device_id: &str, msg: &ValidatorMessage)
pub async fn send_to(&self, device_id: &str, msg: &ValidatorMessage)
Push a message to a specific miner.
Auto Trait Implementations§
impl !Freeze for Messaging
impl !RefUnwindSafe for Messaging
impl !UnwindSafe for Messaging
impl Send for Messaging
impl Sync for Messaging
impl Unpin for Messaging
impl UnsafeUnpin for Messaging
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more