From 1d4e31cca9ae022865d38109b17d7e258cb37579 Mon Sep 17 00:00:00 2001 From: Alexander Bondarenko <486682+dpwiz@users.noreply.github.com> Date: Thu, 2 May 2024 15:42:50 +0300 Subject: [PATCH] add AERR to pass background errors to client --- src/Simplex/Messaging/Agent.hs | 2 +- src/Simplex/Messaging/Agent/Protocol.hs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Simplex/Messaging/Agent.hs b/src/Simplex/Messaging/Agent.hs index 846ffc051..487f38eb9 100644 --- a/src/Simplex/Messaging/Agent.hs +++ b/src/Simplex/Messaging/Agent.hs @@ -1965,7 +1965,7 @@ subscriber c@AgentClient {subQ, msgQ} = forever $ do runExceptT (processSMPTransmission c t) >>= \case Left e -> do logError $ tshow e - atomically $ writeTBQueue subQ ("", "", APC SAEConn $ ERR e) + atomically $ writeTBQueue subQ ("", "", APC SAENone $ AERR e) Right _ -> return () cleanupManager :: AgentClient -> AM' () diff --git a/src/Simplex/Messaging/Agent/Protocol.hs b/src/Simplex/Messaging/Agent/Protocol.hs index 98db26ab4..c34e41957 100644 --- a/src/Simplex/Messaging/Agent/Protocol.hs +++ b/src/Simplex/Messaging/Agent/Protocol.hs @@ -411,6 +411,7 @@ data ACommand (p :: AParty) (e :: AEntity) where STAT :: ConnectionStats -> ACommand Agent AEConn OK :: ACommand Agent AEConn ERR :: AgentErrorType -> ACommand Agent AEConn + AERR :: AgentErrorType -> ACommand Agent AENone SUSPENDED :: ACommand Agent AENone -- XFTP commands and responses RFPROG :: Int64 -> Int64 -> ACommand Agent AERcvFile @@ -474,6 +475,7 @@ data ACommandTag (p :: AParty) (e :: AEntity) where STAT_ :: ACommandTag Agent AEConn OK_ :: ACommandTag Agent AEConn ERR_ :: ACommandTag Agent AEConn + AERR_ :: ACommandTag Agent AENone SUSPENDED_ :: ACommandTag Agent AENone -- XFTP commands and responses RFDONE_ :: ACommandTag Agent AERcvFile @@ -530,6 +532,7 @@ aCommandTag = \case STAT _ -> STAT_ OK -> OK_ ERR _ -> ERR_ + AERR _ -> AERR_ SUSPENDED -> SUSPENDED_ RFPROG {} -> RFPROG_ RFDONE {} -> RFDONE_ @@ -1677,6 +1680,7 @@ instance StrEncoding ACmdTag where "STAT" -> ct STAT_ "OK" -> ct OK_ "ERR" -> ct ERR_ + "AERR" -> nt AERR_ "SUSPENDED" -> nt SUSPENDED_ "RFPROG" -> at SAERcvFile RFPROG_ "RFDONE" -> at SAERcvFile RFDONE_ @@ -1735,6 +1739,7 @@ instance (APartyI p, AEntityI e) => StrEncoding (ACommandTag p e) where STAT_ -> "STAT" OK_ -> "OK" ERR_ -> "ERR" + AERR_ -> "AERR" SUSPENDED_ -> "SUSPENDED" RFPROG_ -> "RFPROG" RFDONE_ -> "RFDONE" @@ -1801,6 +1806,7 @@ commandP binaryP = STAT_ -> s (STAT <$> strP) OK_ -> pure OK ERR_ -> s (ERR <$> strP) + AERR_ -> s (AERR <$> strP) SUSPENDED_ -> pure SUSPENDED RFPROG_ -> s (RFPROG <$> A.decimal <* A.space <*> A.decimal) RFDONE_ -> s (RFDONE <$> strP) @@ -1869,6 +1875,7 @@ serializeCommand = \case STAT srvs -> s (STAT_, srvs) CON pqEnc -> s (CON_, pqEnc) ERR e -> s (ERR_, e) + AERR e -> s (AERR_, e) OK -> s OK_ SUSPENDED -> s SUSPENDED_ RFPROG rcvd total -> s (RFPROG_, rcvd, total)