mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-23 04:22:13 +00:00
Notify about handover errors
This commit is contained in:
1 parent
af2df8d489
commit
6c0d1b5f15
4 files changed
+20
-15
No files matched your search
+11
-12
@@ -132,19 +132,18 @@ startRemoteCtrl =
|
||||
uiEvent <- async $ atomically $ readTMVar accepted
|
||||
waitEitherCatchCancel listener uiEvent >>= \case
|
||||
Left _ -> pure () -- discover got cancelled or crashed on some UDP error
|
||||
Right (Left _) -> pure () -- readTMVar blocked indefinitely (should not happen)
|
||||
Right (Right remoteCtrlId) -> do
|
||||
Right (Left _) -> toView . CRChatError Nothing . ChatError $ CEException "Crashed while waiting for remote session confirmation"
|
||||
Right (Right remoteCtrlId) ->
|
||||
-- got connection confirmation
|
||||
(source, fingerprint) <-
|
||||
atomically $
|
||||
TM.lookup remoteCtrlId discovered >>= \case
|
||||
Nothing -> error "Session accepted without getting registered"
|
||||
Just found -> found <$ writeTVar discovered mempty -- flush unused sources
|
||||
host <- async $ runRemoteHost remoteCtrlId source fingerprint
|
||||
chatWriteVar remoteCtrlSession $ Just RemoteCtrlSession {ctrlAsync = host, accepted}
|
||||
_ <- waitCatch host
|
||||
chatWriteVar remoteCtrlSession Nothing
|
||||
toView $ CRRemoteCtrlStopped {remoteCtrlId}
|
||||
atomically (TM.lookup remoteCtrlId discovered) >>= \case
|
||||
Nothing -> toView . CRChatError Nothing . ChatError $ CEInternalError "Remote session accepted without getting discovered first"
|
||||
Just (source, fingerprint) -> do
|
||||
atomically $ writeTVar discovered mempty -- flush unused sources
|
||||
host <- async $ runRemoteHost remoteCtrlId source fingerprint
|
||||
chatWriteVar remoteCtrlSession $ Just RemoteCtrlSession {ctrlAsync = host, accepted}
|
||||
_ <- waitCatch host
|
||||
chatWriteVar remoteCtrlSession Nothing
|
||||
toView $ CRRemoteCtrlStopped {remoteCtrlId}
|
||||
chatWriteVar remoteCtrlSession $ Just RemoteCtrlSession {ctrlAsync = listener, accepted}
|
||||
pure CRRemoteCtrlStarted
|
||||
|
||||
|
||||
Reference in new issue
Block a user