KeypleTerminal

class KeypleTerminal(reader: LocalReader, clientId: String, networkClient: SyncNetworkClient, cardSelectionScenarioJsonString: String = "")

KeypleTerminal is the entry point to the Keyple Distributed Client Library. Provided an instance of a NFC reader, and a NetworkClient, this object will handle the Card Selection Scenario if any, connect the NFC Card to the Keyple server and execute the commands sent by the server.

Use waitForCard for synchronous card detection or waitForCard with a callback parameter for asynchronous detection.

Then use executeRemoteService to start the Keyple transaction.

Parameters

cardSelectionScenarioJsonString

An optional Card Selection Strategy Json string. See Selection JSON Specification here to learn more

Constructors

Link copied to clipboard
constructor(reader: LocalReader, clientId: String, networkClient: SyncNetworkClient, cardSelectionScenarioJsonString: String = "")

Functions

Link copied to clipboard
suspend fun executeRemoteService(serviceId: String, inputData: String? = null): KeypleResult<String?>
suspend fun <T, R> executeRemoteService(serviceId: String, inputData: T? = null, inputSerializer: KSerializer<T>, outputDeserializer: KSerializer<R>): KeypleResult<R?>

Execute a remote service on the Keyple server. This suspend method will communicate back and forth, over the network with the keyple server, and over NFC with the card. The server drives the transaction, requesting the card to execute APDU commands. APDU responses are sent back to the server, that can process them and decide to send new APDU commands to execute, as many time as needed.

Link copied to clipboard
fun release()

Stop scanning for NFC cards. Release the reader resources.

Link copied to clipboard
Link copied to clipboard
fun setCardSelectionScenarioJsonString(cardSelectionScenarioJsonString: String)

Injects the card selection scenario that has been retrieved by your own means (from your server for example).

Link copied to clipboard
fun setScanMessage(message: String)

Set the scan instructions to the user, for applicable NFC readers. (Displayed on the iOS system "NFC reader" popup)

Link copied to clipboard
suspend fun waitForCard(): Boolean

Suspends until a card is detected.

fun waitForCard(onCardDetected: () -> Unit)

Starts monitoring the reader for card detection events asynchronously.