TouchPortal-CS-API 1.44.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package TouchPortal-CS-API --version 1.44.2                
NuGet\Install-Package TouchPortal-CS-API -Version 1.44.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TouchPortal-CS-API" Version="1.44.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TouchPortal-CS-API --version 1.44.2                
#r "nuget: TouchPortal-CS-API, 1.44.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install TouchPortal-CS-API as a Cake Addin
#addin nuget:?package=TouchPortal-CS-API&version=1.44.2

// Install TouchPortal-CS-API as a Cake Tool
#tool nuget:?package=TouchPortal-CS-API&version=1.44.2                

Touch Portal C# API

Nuget .NET License

Originally a fork of https://github.com/oddbear/TouchPortalSDK, optimized for performance, usability, and good behavior (eg. not crashing on exit). See further details below.


Touch Portal API for making plugins with C#

Built based on documentation at Touch Portal Plugin API.

Getting started:

The simplest way of getting started, is to implement the ITouchPortalEventHandler and use TouchPortalFactory to create a client. And then Connect to Touch Portal before sending or receiving events.

public class SamplePlugin : ITouchPortalEventHandler
{
    public string PluginId => "Plugin.Id"; //Replace "Plugin.Id" with your unique id.

    private readonly ITouchPortalClient _client;

    public SamplePlugin()
    {
        _client = TouchPortalFactory.CreateClient(this);
    }

    public void Run()
    {
        _client.Connect();
    }
    ...

More information on the original Wiki, or see the Sample project in this repository.

Compatibility With Original

Drop-in replacement for oddbear's TouchPortalSDK as of his v0.30.0-beta2, except:

  • The ActionEvent.Data property, which was an array or key-value pairs, is now a Dictionary<string, string> with each data ID mapped to its corresponding value. See the SamplePllugin.cs changes on this commit for how to update (but now you can also message.Data.TryGetValue("myDataId", out string value), for example).

Since oddbear's TouchPortalSDK v 0.30.0 release version, the paths have diverged further, most notably in the handling of TP Connectors.

New Features

v 1.44.0
  • Add TP API v6 parentGroup parameter for dynamic state creation.
  • Add static TouchPortalOptions.ValidateCommandParameters setting to bypass all parameter validation when creating new Command types.
v0.43.0-mp
  • Add ConnectorChangeEvent.Data property to get Connector data members (structure is identical to Actions). ConnectorChangeEvent and ActionEvent now have a common base class DataContainerEventBase. commit
  • Add ShortConnectorIdNotification event. commit
  • Add ConnectorUpdateShort() command to send connector updates based on their shortId (from the above notification event).
    commit sample
  • Add TouchPortalClient.IsConnected property.
  • TouchPortalClient now sends the OnCloseEvent() to the plugin before disconnecting, so the plugin can send any final data updates, etc (unless TP just crashed or quit, of course).
  • ShortConnectorIdNotificationEvent.Data property will parse all the |setting1=testvalue|setting2=anothervalue action data pairs from the long connectorId string into a Dictionary<string, string>. Also the ActualConnectorId property is available to get the actual connector ID part (before any data=value pairs).
    commit
  • Add static TouchPortalOptions.ActionDataIdSeparator option to split action data IDs on a character and only store the last part in the dictionary key (eg. for IDs like <plugin>.<category>.<action>.<data1> one could split on the period and have much shorter/simpler key lookups). commit
Some other changes:
  • Does not crash on shutdown. Your plugin code can clean up and shut down properly.
  • Benchmarked at around 30-50% better performance/throughput in several areas like JSON de-serialization and actual socket efficiency (removes 2 layers of buffers and reads/writes UTF8 JSON bytes directly).
  • Log verbosity at the Info level greatly reduced. Logging in general improved and made more consistent, especially at Debug level.

Plugins Using This API

Working examples at:

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.46.1 31 11/16/2024
1.46.0 284 8/4/2023
1.45.1 505 7/18/2022
1.45.0 437 7/18/2022 1.45.0 is deprecated.
1.44.2 435 7/7/2022
1.44.1 464 7/7/2022 1.44.1 is deprecated.
1.44.0 449 7/7/2022 1.44.0 is deprecated.

Please see the front-page README at repository.