use sync commands (#319)

This commit is contained in:
Evgeny Poberezkin
2022-02-16 20:31:26 +00:00
committed by GitHub
parent ec70670630
commit f8951b44fc
3 changed files with 14 additions and 13 deletions
+10 -10
View File
@@ -382,17 +382,17 @@ processChatCommand = \case
withAgentLock a . withLock l $ action
-- below code would make command responses asynchronous where they can be slow
-- in View.hs `r'` should be defined as `id` in this case
procCmd :: m ChatResponse -> m ChatResponse
procCmd action = do
ChatController {chatLock = l, smpAgent = a, outputQ = q, idsDrg = gVar} <- ask
corrId <- liftIO $ SMP.CorrId <$> randomBytes gVar 8
void . forkIO $
withAgentLock a . withLock l $
(atomically . writeTBQueue q) . (Just corrId,) =<< (action `catchError` (pure . CRChatError))
pure $ CRCmdAccepted corrId
-- use function below to make commands "synchronous"
-- procCmd :: m ChatResponse -> m ChatResponse
-- procCmd = id
-- procCmd action = do
-- ChatController {chatLock = l, smpAgent = a, outputQ = q, idsDrg = gVar} <- ask
-- corrId <- liftIO $ SMP.CorrId <$> randomBytes gVar 8
-- void . forkIO $
-- withAgentLock a . withLock l $
-- (atomically . writeTBQueue q) . (Just corrId,) =<< (action `catchError` (pure . CRChatError))
-- pure $ CRCmdAccepted corrId
-- use function below to make commands "synchronous"
procCmd :: m ChatResponse -> m ChatResponse
procCmd = id
connectViaContact :: UserId -> ConnectionRequestUri 'CMContact -> Profile -> m ChatResponse
connectViaContact userId cReq profile = withChatLock $ do
let cReqHash = ConnReqUriHash . C.sha256Hash $ strEncode cReq