core: calls api - support multiple calls, process status updates from webview, refactor, tests (#595)

* core: tests for call api (WIP, test fails)

* fix test

* add APICallStatus, tests

* update call status based on webview events, refactor
This commit is contained in:
Evgeny Poberezkin
2022-05-04 13:31:00 +01:00
committed by GitHub
parent 8e002eed1c
commit 1ddd17839b
8 changed files with 280 additions and 153 deletions
+9 -7
View File
@@ -40,6 +40,7 @@ import qualified Simplex.Messaging.Crypto as C
import Simplex.Messaging.Notifications.Protocol (DeviceToken (..), NtfTknStatus)
import Simplex.Messaging.Parsers (dropPrefix, enumJSON, sumTypeJSON)
import Simplex.Messaging.Protocol (CorrId)
import Simplex.Messaging.TMap (TMap)
import System.IO (Handle)
import UnliftIO.STM
@@ -81,7 +82,7 @@ data ChatController = ChatController
chatLock :: TMVar (),
sndFiles :: TVar (Map Int64 Handle),
rcvFiles :: TVar (Map Int64 Handle),
currentCall :: TVar (Maybe Call),
currentCalls :: TMap ContactId Call,
config :: ChatConfig,
filesFolder :: TVar (Maybe FilePath) -- path to files folder for mobile apps
}
@@ -110,12 +111,13 @@ data ChatCommand
| APIDeleteChat ChatRef
| APIAcceptContact Int64
| APIRejectContact Int64
| APISendCallInvitation Int64 CallType
| APIRejectCall Int64
| APISendCallOffer Int64 WebRTCCallOffer
| APISendCallAnswer Int64 WebRTCSession
| APISendCallExtraInfo Int64 WebRTCExtraInfo
| APIEndCall Int64
| APISendCallInvitation ContactId CallType
| APIRejectCall ContactId
| APISendCallOffer ContactId WebRTCCallOffer
| APISendCallAnswer ContactId WebRTCSession
| APISendCallExtraInfo ContactId WebRTCExtraInfo
| APIEndCall ContactId
| APICallStatus ContactId WebRTCCallStatus
| APIUpdateProfile Profile
| APIParseMarkdown Text
| APIRegisterToken DeviceToken