Description
The Retail Module provides simplified connection and asynchronous communication with a Nexo Retail SaleSystem.
Goal and usage
This Module’s main functionality is to provide and manage an Event stream with a SaleSystem, allowing a Merchant application to efficiently receive triggers for actions such as Payment Requests, Display Requests, Input Requests. It also give simplified ways to provide Response to those events.
A secondary goal of the Retail Module is to manage the connectivity and system state with as little overview from the Merchant application as possible, allowing transparent management of System state. This allows the module to filter events that the Merchant Application is not awaiting, minimizing integration overhead.
For example, while the System is currently in a Service exchange, the module will automatically respond to incoming different Service requests with a Busy
response
How to?
Initialize a Server mode Module
In Server mode, a Retail Module is awaiting a Sale System connection passively. When that connection is lost or terminated, it will go back to awaiting the next one.
To start in Server mode, use the static factory function StartServer
on the AmadisRetailModule
class, providing the port on which to await connections
NexoRetailModule retailModule = NexoRetailModule.StartServer(serverPort);
Initialize a Client mode Module
In Client mode, a Retail Module is actively trying to connect to a Sale System. When that connection is lost or terminated, it will continue trying to reconnect.
To start in Server mode, use the static factory function StartClient
on the AmadisRetailModule
class, providing the hostname and port of the Sale System
NexoRetailModule retailModule = NexoRetailModule.StartClient(saleHostname, salePort);
Poll the Module for Sale events
See Events for the supported event types and specifications
// With timeout in ms NexoEvent event = retailModule.pollTimeout(1000); // Non-blocking NexoEvent event = retailModule.poll(); NexoEventType type = event.GetType(); switch (type) { case Login: {...} [...] }
Respond to a previously polled event
// Previously polled event NexoEvent event = [...]; // Create response data content according to event type byte[] responseData = {...}; // Send response retailModule.respond(event, responseData);
Signal a System state change
retailModule.signal(NexoSignal.CardDetected); retailModule.signal(NexoSignal.Busy); retailModule.signal(NexoSignal.Available);