This commit is contained in:
parent
cf3cccd3ca
commit
04760fd88d
15 changed files with 136 additions and 20 deletions
|
|
@ -1,4 +1,5 @@
|
|||
use mtp_common::CommunicationError;
|
||||
use std::net::SocketAddr;
|
||||
use std::sync::{
|
||||
Arc,
|
||||
atomic::{AtomicBool, Ordering},
|
||||
|
|
@ -10,6 +11,7 @@ pub struct ConnectionHandle {
|
|||
closed: AtomicBool,
|
||||
close_tx: watch::Sender<Option<CommunicationError>>,
|
||||
close_rx: watch::Receiver<Option<CommunicationError>>,
|
||||
remote_addr: Option<SocketAddr>,
|
||||
}
|
||||
|
||||
impl ConnectionHandle {
|
||||
|
|
@ -19,9 +21,20 @@ impl ConnectionHandle {
|
|||
closed: AtomicBool::new(false),
|
||||
close_tx,
|
||||
close_rx,
|
||||
remote_addr: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_remote_addr(remote_addr: SocketAddr) -> Self {
|
||||
let mut handle = Self::new();
|
||||
handle.remote_addr = Some(remote_addr);
|
||||
handle
|
||||
}
|
||||
|
||||
pub fn remote_addr(&self) -> Option<SocketAddr> {
|
||||
self.remote_addr
|
||||
}
|
||||
|
||||
pub fn is_open(&self) -> bool {
|
||||
!self.closed.load(Ordering::SeqCst)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue