mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-28 02:54:34 +00:00
Notify about handover errors
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@ constraints: zip +disable-bzip2 +disable-zstd
|
||||
source-repository-package
|
||||
type: git
|
||||
location: https://github.com/simplex-chat/simplexmq.git
|
||||
tag: 681fa93bf342d7c836fa0ff69b767dcd08526f03
|
||||
tag: ec1b72cb8013a65a5d9783104a47ae44f5730089
|
||||
|
||||
source-repository-package
|
||||
type: git
|
||||
|
||||
@@ -913,7 +913,7 @@ data ChatError
|
||||
| ChatErrorAgent {agentError :: AgentErrorType, connectionEntity_ :: Maybe ConnectionEntity}
|
||||
| ChatErrorStore {storeError :: StoreError}
|
||||
| ChatErrorDatabase {databaseError :: DatabaseError}
|
||||
| ChatErrorRemoteCtrl {remoteControllerError :: RemoteCtrlError}
|
||||
| ChatErrorRemoteCtrl {remoteCtrlError :: RemoteCtrlError}
|
||||
| ChatErrorRemoteHost {remoteHostId :: RemoteHostId, remoteHostError :: RemoteHostError}
|
||||
deriving (Show, Exception, Generic)
|
||||
|
||||
|
||||
+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
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
module Simplex.Chat.Remote.Types where
|
||||
|
||||
import Control.Concurrent.Async (Async)
|
||||
import Data.Aeson (ToJSON)
|
||||
import Data.Aeson (ToJSON (..))
|
||||
import Data.ByteString.Char8 (ByteString)
|
||||
import Data.Int (Int64)
|
||||
import Data.Text (Text)
|
||||
@@ -13,6 +13,7 @@ import GHC.Generics (Generic)
|
||||
import qualified Simplex.Messaging.Crypto as C
|
||||
import Simplex.Messaging.Transport.HTTP2.Client (HTTP2Client)
|
||||
import UnliftIO.STM
|
||||
import Simplex.Messaging.Encoding.String (strToJEncoding, strToJSON)
|
||||
|
||||
type RemoteHostId = Int64
|
||||
|
||||
@@ -38,6 +39,11 @@ data RemoteCtrl = RemoteCtrl
|
||||
}
|
||||
deriving (Show, Generic, ToJSON)
|
||||
|
||||
-- XXX: until fixed in master
|
||||
instance ToJSON C.KeyHash where
|
||||
toEncoding = strToJEncoding
|
||||
toJSON = strToJSON
|
||||
|
||||
data RemoteHostSession = RemoteHostSession
|
||||
{ -- | Path for local resources to be synchronized with host
|
||||
storePath :: FilePath,
|
||||
|
||||
Reference in New Issue
Block a user