public interface MessageObserver
Modifier and Type | Method and Description |
---|---|
void |
messageAvailable(String mountPoint,
ParsedMessage message)
Notify that an encoded message is available.
|
void messageAvailable(String mountPoint, ParsedMessage message)
Beware that this method will be called from an internal dedicated stream-reading thread. Implementations must take to:
The only filtering that can be specified when adding
an observer to a
NtripClient
is based on message type and mount point. If additional filtering
is needed (for example on message content like satellites ids, it must be performed
by the observer itself when notified (see example below).
The recommended way to implement this method is to simply build a domain object
from the message fields (for example a gnss propagator) and to store it in the
observer class as an instance field using a AtomicReference
as follows:
public class GPSProvider implements PVCoordinatesProvider, RTCMMessageObserver { private final int filteringId; private final AtomicReference<GPSPropagator> propagator; public void messageAvailable(String mountPoint, ParsedMessage message) { MessageXXX msg = (MessageXXX) message; GPSPropagator oldPropagator = propagator.get(); if (msg.getSatId() == filteringId) { GPSPropagator newPropagator = new GPSPropagator(msg.get...(), msg.get...(), msg.get...()); // only set propagator if no other observer was notified // while we were asleep propagator.compareAndSet(oldPropagator, newPropagator); } } public TimeStampedPVCoordinates getPVCoordinates(AbsoluteDate date, Frame frame) { GPSPropagator lastAvailablePropagator = propagator.get(); // use the retrieved propagator to compute position-velocity } }
mountPoint
- mount point from which the message comesmessage
- last available messageCopyright © 2002-2021 CS GROUP. All rights reserved.