Skip to main content

DataSync Network

DataSync uses the Transmission Control Protocol (TCP) and User Datagram Protocl (UDP) to receive and send messages. Through DataSync, the terminals can listen to their local network for messages, broadcast the messages to the network, and communicate with other terminals at their IP address.

TCP

The Transmission Control Protocol (TCP) is used for point communication between terminals. TCP allows communication between two terminals through their IP addresses. TCP receives a message from the other terminal and confirms receipt of the message by sending the terminal a status of 200, but does not respond to it, as in normal HTTP.

With XMLHttpRequest, the sending terminal creates POST requests to the other terminal directly to its IP address. Requests contain the necessary action in the request body, such as getting the entity, and data for transmission to another terminal.

With the implementation of the TCP plugin, the server does not know how to wait for a response from the other side. All communication between terminals is carried out through requests only without an answer to them. The TCP server can know only if the message was delivered.

In each POST request, the identifier of the request is added, which is necessary to determine which request is received and whether to process it or respond to it.

An Example of a TCP Message

{ 
"request_id": "27c98301-9179-4a9c-8cf6-836a3686fc2f",
 "type": "request",
 "action": "resources-list",
 "data": {
   "feedType": "orderState"
   }
}

Field Name

Type

Description

request_id

string

The identifier of the request

type

string

The possible values: request or response

action

string

The type of action. The possible values: resources-list or entity

data

object

Contains information about the feed or entities. For example, the entity identifier or whole entity.

feedType

string

The name of the feed which must exist in each request/response

UDP

The User Datagram Protocol (UDP) is used to broadcast the terminal’s state to the entire network and to receive notification from other terminals. Sending a UDP message does not happen directly to the selected terminal, but directly to the public local network. The public local network has already received the message by each of the devices, and has raised the UDP server on the specified port.

One UDP message format is the minimum required data set of one feed to determine the difference between the local and remote feeds of two terminals, which is necessary because the size of a single UDP message should not exceed 4096KB.

The first terminal to receive a UDP message determines through the message's channel if the incoming message belongs to the site within which it operates. It is necessary that the data in one site should not be mixed with the data of another.

Unless an administrator explicitly enables multi-cast for DataSync, all terminals need to be in the same subnet.

An Example of a Broadcast UDP Message

"XPOS{
 "meta": {
   "name": "XPOS:4065",
   "sender": {
     "port": 12000,
     "address": "172.17.6.108"
   },
   "channel": "XPOS:5a7432f64b0142001677b950"
   }, 
   "payload": {
     "feed": "orderState",
     "count": 150,
     "updateTime": 1525440936663
   }
}"

Field Name

Type

Description

XPOS

string

A string for determining from which application the message was sent

meta

object

The meta information about the terminal who sent message

sender

object

The sender's network address

port

number

An endpoint of communication

address

string

The IP address of the sender

channel

string

Indicates which application sent the message, such as POS-APP or MobileOrdering, and is the unique identifier of the site in which the application is running

payload

object

The data with feed state

feed

string

The type of feed

count

number

The amount of entities in the database collection

updateTime

number

The time of the latest update of the collection with entities