pub(crate) struct XlxMonitor {
socket: UdpSocket,
peer: SocketAddr,
reflector: String,
}Expand description
A UDP client connected to a single XLX reflector’s monitor port.
Manages the UDP socket lifecycle and provides async methods for receiving
parsed monitor messages. Create via XlxMonitor::connect and receive
events via XlxMonitor::recv.
On drop, a best-effort "bye" datagram is sent to the reflector so it can
clean up its client tracking state promptly.
Fields§
§socket: UdpSocketThe bound UDP socket, connected to the reflector’s monitor port.
peer: SocketAddrThe reflector’s monitor endpoint (ip:10001).
reflector: StringReflector callsign for logging and database correlation.
Implementations§
Source§impl XlxMonitor
impl XlxMonitor
Sourcepub(crate) async fn connect(
ip: IpAddr,
reflector: String,
) -> Result<Self, Error>
pub(crate) async fn connect( ip: IpAddr, reflector: String, ) -> Result<Self, Error>
Connects to a reflector’s XLX monitor port and sends the "hello"
handshake.
Binds a new UDP socket on an ephemeral port, “connects” it to the
reflector’s monitor address (so that subsequent send/recv calls are
scoped to this peer), and sends the initial "hello" datagram.
The reflector will respond with three JSON datagrams (reflector info,
nodes snapshot, stations snapshot) which can be read via recv.
§Errors
Returns io::Error if socket binding or the initial send fails.
Sourcepub(crate) async fn recv(&self) -> Option<MonitorMessage>
pub(crate) async fn recv(&self) -> Option<MonitorMessage>
Receives the next monitor message from the reflector.
Blocks (asynchronously) until a UDP datagram arrives or the 30-second timeout expires. Returns:
Some(message)— a successfully parsedMonitorMessage.None— the timeout expired (no data received within 30 seconds), or the received datagram was not valid JSON and could not be parsed at all (not even asUnknown).
The caller should treat repeated None returns as a signal that the
reflector is unresponsive and consider reconnecting.
Sourcepub(crate) const fn peer(&self) -> SocketAddr
pub(crate) const fn peer(&self) -> SocketAddr
Returns the peer socket address (ip:10001).
Trait Implementations§
Source§impl Debug for XlxMonitor
impl Debug for XlxMonitor
Source§impl Drop for XlxMonitor
impl Drop for XlxMonitor
Source§fn drop(&mut self)
fn drop(&mut self)
Best-effort "bye" on drop.
Uses try_send (non-async, non-blocking) because Drop cannot be
async. If the send fails (e.g., the socket is already closed or the
runtime is shutting down), the failure is silently ignored — the
reflector will eventually time out the client entry on its own.
Auto Trait Implementations§
impl !Freeze for XlxMonitor
impl RefUnwindSafe for XlxMonitor
impl Send for XlxMonitor
impl Sync for XlxMonitor
impl Unpin for XlxMonitor
impl UnwindSafe for XlxMonitor
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more