Communication with Touch Portal
When you setup your plug-in as a dynamic plug-in you are required to have
an plug-in application or service running that will connect to Touch Portal
using a Socket communication. Touch Portal will listen to calls from your
plug-in and will send information to your plug-in.
From version 3 of the plug-in API, all communication is done in UTF-8 encoding.
Touch Portal communicates with JSON formatted
strings. So ensure that each call you make to Touch Portal is in the JSON format.
Sending a piece of data to Touch Portal should always end with a newline
character. This will indicate Touch Portal that it is the whole message.
Pairing your plug-in
Before you can listen to and send message you need to pair your plug-in with
Touch Portal. Once the pairing is succesful you will be able to send and listen.
To pair your plug-in, follow the steps below.
Step 1: Open socket
First step is to make a connection to the local host using the ip 127.0.0.1
on the port 12136. Touch Portal is listening on this port and when you connect
Touch Portal will start listening to the pair request.
If the user uses the external computer connection settings (see Tools) the
ip 127.0.0.1 will not connect and neither will localhost. It all depends on
what the user has set up in that regard. To support the external
computer connection setting you need to provide your user with an option to
change the connection information if need be. As this setting is used before
a connection with Touch Portal is made, it cannot be set in the plug-in
settings within Touch Portal. We suggest to add a config text file or similar
to allow the users to customize that part of the plug-in.
Step 2: Pairing the plugin
Once the connection is made, we need to let Touch Portal know who we are.
The first thing you need to send is the pairing message (this message is in a JSON format).
This pairing message will let Touch Portal know what plugin is
communicating on this socket. Touch Portal will send all communicate actions through this channel with the
Touch Portal will return an info message when the pairing is successful
"sdkVersion":"(SDK version code)",
"tpVersionString":"(Version of Touch Portal in string format)",
"tpVersionCode":"(Version of Touch Portal in code format)",
"pluginVersion":"(Your plug-in version)"