diff --git a/README.md b/README.md index c6327f6..b34cc54 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,12 @@ for how to update (but now you can also `message.Data.TryGetValue("myDataId", ou 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 +### New Features & Change Log + +#### v 1.45.0 +Both changes affect the feature which parses the "Long" connector ID from the short ID notification events into individual key/value fields (see notes for v0.43.0-mp below). +* Connector data key names are now truncated if `TouchPortalOptions.ActionDataIdSeparator` is set, just like action/connector data keys. +* Fix that the "pc_plugin-name_" part wasn't properly stripped from the "actual" connector ID. #### v 1.44.0 * Add TP API v6 `parentGroup` parameter for dynamic state creation. diff --git a/TouchPortalSDK/Configuration/ConnectorIdParser.cs b/TouchPortalSDK/Configuration/ConnectorIdParser.cs index 609b000..98aa139 100644 --- a/TouchPortalSDK/Configuration/ConnectorIdParser.cs +++ b/TouchPortalSDK/Configuration/ConnectorIdParser.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; using TouchPortalSDK.Messages.Models; namespace TouchPortalSDK.Configuration @@ -31,22 +29,27 @@ public ConnectorIdParser(string connectorId, string pluginId = null) { var values = connectorId?.Split('|', StringSplitOptions.RemoveEmptyEntries); // get our actual connector id - ConnectorIdPart = values.FirstOrDefault(); + ConnectorIdPart = values.Length > 0 ? values[0] : null; if (string.IsNullOrWhiteSpace(ConnectorIdPart)) return; if (!string.IsNullOrWhiteSpace(pluginId)) - ConnectorIdPart.Replace("pc_" + pluginId + "_", ""); + ConnectorIdPart = ConnectorIdPart.Replace("pc_" + pluginId + "_", ""); for (int i = 1, e = values.Length; i < e; ++i) { var keyVal = values[i].Split('=', StringSplitOptions.RemoveEmptyEntries); var len = keyVal.Length; + if (len == 0) + continue; + var key = keyVal[0]; + if (TouchPortalOptions.ActionDataIdSeparator != '\0') + key = key.Split(TouchPortalOptions.ActionDataIdSeparator, StringSplitOptions.RemoveEmptyEntries)[^1]; if (len == 2) - _kvPairs.Add(keyVal[0], keyVal[1]); + _kvPairs.Add(key, keyVal[1]); else if (len == 1) - _kvPairs.Add(keyVal[0], ""); + _kvPairs.Add(key, ""); else if (len > 2) - _kvPairs.Add(keyVal[0], string.Join('=', keyVal[1..^0])); + _kvPairs.Add(key, string.Join('=', keyVal[1..^0])); } } } diff --git a/TouchPortalSDK/TouchPortalSDK.csproj b/TouchPortalSDK/TouchPortalSDK.csproj index 1044445..da2d4dd 100644 --- a/TouchPortalSDK/TouchPortalSDK.csproj +++ b/TouchPortalSDK/TouchPortalSDK.csproj @@ -2,7 +2,8 @@ net5.0 - 1.44.2 + 1.45.0 + 1.45.0.0 Maxim Paperno, Oddbjørn U. Bakke https://github.com/mpaperno/TouchPortal-CS-API https://github.com/mpaperno/TouchPortal-CS-API.git @@ -26,7 +27,6 @@ True none signing_key.snk - 1.44.2.0 en true