Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

Description

Goals and usage

...

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.

Info

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

Code Block
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

Code Block
NexoRetailModule retailModule = NexoRetailModule.StartClient(saleHostname, salePort);

Poll the Module for Sale events

Code Block
// With timeout in ms
NexoEvent event = retailModule.pollTimeout(1000);

// Non-blocking
NexoEvent event = retailModule.poll();

Respond to a previously polled event

Code Block
// 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

Code Block
retailModule.signal(NexoSignal.CardDetected);

retailModule.signal(NexoSignal.Busy);
retailModule.signal(NexoSignal.Available);