IReaderListener
com.rvi.application.IReaderListener · Interface · SocialCard 1.0.3
Define callbacks for card insertion, removal and monitor failures.
When to use it
Section titled “When to use it”Implement onCardInserted(terminal), onCardRemoved(terminal) and onError(exception). For a UI, use the appropriate dispatch mechanism, such as JavaFX Platform.runLater, before changing UI state from a callback.
Java example
Section titled “Java example”final IReaderListener listener = new IReaderListener() { @Override public void onCardInserted(final CardTerminal terminal) { System.out.println("Card inserted on " + terminal.getName()); }
@Override public void onCardRemoved(final CardTerminal terminal) { System.out.println("Card removed from " + terminal.getName()); }
@Override public void onError(final Exception failure) { System.err.println(failure.getMessage()); }};Java imports
import com.rvi.application.IReaderListener;import javax.smartcardio.CardTerminal;Pass this listener to new ReaderMonitor(terminal, listener) to observe events without modifying tags.
How it works
Section titled “How it works”ReaderMonitor invokes callbacks on its worker thread. Both card events carry the same watched terminal. An uncaught runtime error in an event callback can stop monitoring, so handle recoverable application failures at the callback boundary.