Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] Add timeout for stop casting

Neeraj Gupta195ad01f148d
diff --git a/mobile/plugins/ente_cast_normal/lib/src/service.dart b/mobile/plugins/ente_cast_normal/lib/src/service.dart
index a2c4206c87..454af58adf 100644
--- a/mobile/plugins/ente_cast_normal/lib/src/service.dart
+++ b/mobile/plugins/ente_cast_normal/lib/src/service.dart
@@ -71,9 +71,16 @@ class CastServiceImpl extends CastService {
final sessions = CastSessionManager().sessions;
for (final session in sessions) {
debugPrint("send close message for ${session.sessionId}");
- session.sendMessage(CastSession.kNamespaceConnection, {
- 'type': 'CLOSE',
- });
+ Future(() {
+ session.sendMessage(CastSession.kNamespaceConnection, {
+ 'type': 'CLOSE',
+ });
+ }).timeout(
+ const Duration(seconds: 5),
+ onTimeout: () {
+ print('sendMessage timed out after 5 seconds');
+ },
+ );
debugPrint("close session ${session.sessionId}");
session.close();
}