From 2e57331c25ee5c9ba61894627194a134ab7087c5 Mon Sep 17 00:00:00 2001 From: David Scheutz Date: Thu, 3 Nov 2022 14:22:29 -0700 Subject: [PATCH] listen for socket updates until we have all the required data --- .../Packages/Sources/SecretAgentKit/SocketController.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/Packages/Sources/SecretAgentKit/SocketController.swift b/Sources/Packages/Sources/SecretAgentKit/SocketController.swift index 3143d995..a8e1ff3c 100644 --- a/Sources/Packages/Sources/SecretAgentKit/SocketController.swift +++ b/Sources/Packages/Sources/SecretAgentKit/SocketController.swift @@ -78,11 +78,13 @@ public class SocketController { Logger().debug("Socket controller has new data available") guard let new = notification.object as? FileHandle else { return } Logger().debug("Socket controller received new file handle") - if((handler?(new, new)) == true) { + let didHandle = handler?(new, new) == true + + if didHandle { Logger().debug("Socket controller handled data, wait for more data") new.waitForDataInBackgroundAndNotify() } else { - Logger().debug("Socket controller called with empty data, socked closed") + Logger().debug("Socket controller called with not enough empty data, waiting for more data...") } }