JSON Client
The JSON Client remote is the counterpart of the JSON Server: mAirList connects to a TCP server, and exchanges JSON messages with it. The received data is passed to background scripts for processing.
Configuration
In the configuration app or Control Panel, go to Remote Control and add an interface of type JSON Client (Network category).
Enter the Host name or IP and Port of the server to connect to. The default port is 9303.
mAirList connects automatically when the interface is started, and tries to reconnect every few seconds if the connection is lost or cannot be established.
Protocol
Each message is a JSON document, encoded as UTF-8 and terminated by a null byte (ASCII 0), the same as for the JSON Server.
Scripting
The following event handlers are available in background scripts:
procedure OnJSONClientRemoteConnect(Remote: IJSONClientRemote; ClientID: cardinal);
procedure OnJSONClientRemoteDisconnect(Remote: IJSONClientRemote; ClientID: cardinal);
procedure OnJSONClientRemoteData(Remote: IJSONClientRemote; Data: IPersistentStorage);
procedure OnJSONClientRemoteDataObject(Remote: IJSONClientRemote; Data: IPersistentObject);
OnJSONClientRemoteConnect and OnJSONClientRemoteDisconnect are called whenever the
connection to the server is (re-)established or lost. Their ClientID parameter is always
0; it only exists for compatibility with the JSON Server event handlers.
OnJSONClientRemoteDataObject is only called when the received document is a JSON
object.
To send data to the server, call Remote.Send(Data) (or JSONClientRemote(<index>).Send(Data)).
For sending a single JSON document to a server without setting up a remote control
interface, scripts can use the JSONSendString(Server, Port, Data) procedure.