Skip to content

ReaderMonitor

com.rvi.application.ReaderMonitor · Class · SocialCard 1.0.3

Observe insertion and removal of cards on one PC/SC terminal.

Construct the monitor from an existing CardTerminal and an IReaderListener. Call start() once and keep it open until monitoring is no longer needed. In a desktop app, store the monitor and close it when the window closes.

static ReaderMonitor startMonitor(final CardTerminal terminal, final IReaderListener listener) {
final ReaderMonitor monitor = new ReaderMonitor(terminal, listener);
monitor.start();
return monitor; // The caller must close this when finished.
}
Java imports
import com.rvi.application.IReaderListener;
import com.rvi.application.ReaderMonitor;
import javax.smartcardio.CardTerminal;

Create a new monitor if you need to restart after it stops.

A single background worker waits for presence, invokes the insert callback, then waits for absence. An uncaught card or runtime error is forwarded to onError() and ends the worker. close() requests a stop and does not wait for a callback already running to finish.

IReaderListener · ReaderListener · ReaderService

Method signatures in the Javadoc · All API types