-
-
Notifications
You must be signed in to change notification settings - Fork 4
Sockets
Oddbjørn Bakke edited this page May 9, 2021
·
7 revisions
A plugin connects to port 12136
to communicate with TouchPortal.
From version 2.3 of TouchPortal, the messages can be UTF8 (without BOM / UTF8 Identifier), before that it used standard ASCII.
A message must end with a line shift to indicate that it's finished.
All you need to get started to write your own SDK, is this:
var ipAddress = IPAddress.Parse("127.0.0.1");
var socketAddress = new IPEndPoint(ipAddress, 12136);
var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
socket.Connect(socketAddress);
var encoder = new UTF8Encoding(false); //false: Without BOM
var streamWriter = new StreamWriter(new NetworkStream(socket), encoder) { AutoFlush = true };
var streamReader = new StreamReader(new NetworkStream(socket), encoder);
streamWriter.WriteLine("{\"type\":\"pair\", \"id\":\"TouchPortalSDK.Sample\"}"); //Replace with correct installed plugin id from entry.tp
var message = streamReader.ReadLine();
Console.WriteLine(message);
The next step would be to create a listener thread with the streamReader
, and react upon messages/events from TouchPortal. Commands are sent like in this example, with the streamWriter
.
The Android or iOS device will by default use port 12134
(device to PC) and 12135
(PC to device).
- Home
- Development
- Getting started
- TODO: Entry.tp
- TODO: Commands
- TODO: Events
- Logging
- Parallelization
- TODO: Graphics / Images
- TODO: Plugins with GUI
- Create a .tpp package
- TODO: Creating a installer
- Troubleshooting
- How the SDK works
- Other SDKs