From e738195a2feef40584d4a71d4d9586ab4a71aeb9 Mon Sep 17 00:00:00 2001 From: Jonathan Arndt Date: Sun, 16 Mar 2025 08:12:20 -0700 Subject: [PATCH] fix: correct event subscription logic in GenericCommunicationMonitor and poll inclusively. deregister client.BytesReceived and client.TextReceived events before registering preventing multiple event registrations and trigger poll independant of iSocket condition. --- .../Monitoring/GenericCommunicationMonitor.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/PepperDash.Essentials.Core/Monitoring/GenericCommunicationMonitor.cs b/src/PepperDash.Essentials.Core/Monitoring/GenericCommunicationMonitor.cs index aad8120d..6f854aa0 100644 --- a/src/PepperDash.Essentials.Core/Monitoring/GenericCommunicationMonitor.cs +++ b/src/PepperDash.Essentials.Core/Monitoring/GenericCommunicationMonitor.cs @@ -151,17 +151,16 @@ namespace PepperDash.Essentials.Core { if (MonitorBytesReceived) { - Client.BytesReceived += Client_BytesReceived; + Client.BytesReceived -= Client_BytesReceived; + Client.BytesReceived += Client_BytesReceived; } else { + Client.TextReceived -= Client_TextReceived; Client.TextReceived += Client_TextReceived; } - if (!IsSocket) - { - BeginPolling(); - } + BeginPolling(); } void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e)