From 0fbc8e6650b06d0fc2889f13955fe7012bbde34d Mon Sep 17 00:00:00 2001 From: Max Paperno Date: Fri, 18 Feb 2022 16:32:16 -0500 Subject: [PATCH] Add support for "shortConnectorIdNotification" event. --- TouchPortalSDK/Clients/TouchPortalClient.cs | 3 +++ .../Configuration/MessageResolver.cs | 2 ++ TouchPortalSDK/ITouchPortalEventHandler.cs | 10 +++++++++- .../ShortConnectorIdNotificationEvent.cs | 19 +++++++++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 TouchPortalSDK/Messages/Events/ShortConnectorIdNotificationEvent.cs diff --git a/TouchPortalSDK/Clients/TouchPortalClient.cs b/TouchPortalSDK/Clients/TouchPortalClient.cs index 349736d..a154435 100644 --- a/TouchPortalSDK/Clients/TouchPortalClient.cs +++ b/TouchPortalSDK/Clients/TouchPortalClient.cs @@ -241,6 +241,9 @@ void IMessageHandler.OnMessage(string message) case ConnectorChangeEvent connectorChangeEvent: _eventHandler.OnConnecterChangeEvent(connectorChangeEvent); return; + case ShortConnectorIdNotificationEvent shortConnectorIdEvent: + _eventHandler.OnShortConnectorIdNotificationEvent(shortConnectorIdEvent); + return; //All of Action, Up, Down: case ActionEvent actionEvent: _eventHandler.OnActionEvent(actionEvent); diff --git a/TouchPortalSDK/Configuration/MessageResolver.cs b/TouchPortalSDK/Configuration/MessageResolver.cs index f584000..527da79 100644 --- a/TouchPortalSDK/Configuration/MessageResolver.cs +++ b/TouchPortalSDK/Configuration/MessageResolver.cs @@ -37,6 +37,8 @@ internal static ITouchPortalMessage ResolveMessage(string message) return JsonSerializer.Deserialize(message, Options.JsonSerializerOptions); case "connectorChange": return JsonSerializer.Deserialize(message, Options.JsonSerializerOptions); + case "shortConnectorIdNotification": + return JsonSerializer.Deserialize(message, Options.JsonSerializerOptions); //Commands: case "choiceUpdate": diff --git a/TouchPortalSDK/ITouchPortalEventHandler.cs b/TouchPortalSDK/ITouchPortalEventHandler.cs index ec49f62..bce56d9 100644 --- a/TouchPortalSDK/ITouchPortalEventHandler.cs +++ b/TouchPortalSDK/ITouchPortalEventHandler.cs @@ -43,8 +43,16 @@ public interface ITouchPortalEventHandler /// void OnNotificationOptionClickedEvent(NotificationOptionClickedEvent message); + /// + /// Method to call when a user moves a slider on their device. + /// void OnConnecterChangeEvent(ConnectorChangeEvent message); + /// + /// Called when TP reports a new instance of your connector, either at startup or if user adds/modifies one. + /// + void OnShortConnectorIdNotificationEvent(ShortConnectorIdNotificationEvent message); + /// /// Method to call when we loose connection to Touch Portal. /// @@ -56,4 +64,4 @@ public interface ITouchPortalEventHandler /// void OnUnhandledEvent(string jsonMessage); } -} \ No newline at end of file +} diff --git a/TouchPortalSDK/Messages/Events/ShortConnectorIdNotificationEvent.cs b/TouchPortalSDK/Messages/Events/ShortConnectorIdNotificationEvent.cs new file mode 100644 index 0000000..9dd55da --- /dev/null +++ b/TouchPortalSDK/Messages/Events/ShortConnectorIdNotificationEvent.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; +using System.Linq; +using TouchPortalSDK.Interfaces; +using TouchPortalSDK.Messages.Models; + +namespace TouchPortalSDK.Messages.Events +{ + public class ShortConnectorIdNotificationEvent : ITouchPortalMessage + { + public string Type { get; set; } + public string PluginId { get; set; } + public string ConnectorId { get; set; } + public string ShortId { get; set; } + + public Identifier GetIdentifier() + => new Identifier(Type, ConnectorId, default); + + } +}