File tree 5 files changed +44
-2
lines changed
features/push_notification/presentation/controller
5 files changed +44
-2
lines changed Original file line number Diff line number Diff line change
1
+ # 56. Web Socket Ping Strategy
2
+
3
+ Date: 2024-12-16
4
+
5
+ ## Status
6
+
7
+ Accepted
8
+
9
+ ## Context
10
+
11
+ - Echo ping method takes too much resources from the server
12
+ - Server implemented ping frame
13
+
14
+ ## Decision
15
+
16
+ - Twake Mail no longer have to implement Echo ping
17
+ - Browser will automatically send pong frame as default implementation
18
+ - Echo ping will still be left as an option in ` env.file ` through ` WS_ECHO_PING `
19
+ - Set it to ` true ` if you want to use Echo ping
20
+ - Set it to ` false ` or left it as is if you don't want to use Echo ping
21
+
22
+ ## Consequences
23
+
24
+ - Server resources used will be reduced
Original file line number Diff line number Diff line change
1
+ ## Configuration Web Socket Echo Ping
2
+
3
+ ### Context
4
+ - Echo ping method is optional
5
+ ### How to config
6
+ In [ env.file] :
7
+ - If you want to use Echo ping:
8
+ ``` WS_ECHO_PING=true ```
9
+ - If you don't want to use Echo ping:
10
+ ``` WS_ECHO_PING=false ```
11
+ or
12
+ ``` WS_ECHO_PING= ```
Original file line number Diff line number Diff line change @@ -6,4 +6,5 @@ APP_GRID_AVAILABLE=supported
6
6
FCM_AVAILABLE=supported
7
7
IOS_FCM=supported
8
8
FORWARD_WARNING_MESSAGE=
9
- PLATFORM=other
9
+ PLATFORM=other
10
+ WS_ECHO_PING=
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import 'package:tmail_ui_user/features/push_notification/presentation/extensions
17
17
import 'package:tmail_ui_user/features/push_notification/presentation/listener/email_change_listener.dart' ;
18
18
import 'package:tmail_ui_user/features/push_notification/presentation/listener/mailbox_change_listener.dart' ;
19
19
import 'package:tmail_ui_user/main/routes/route_navigation.dart' ;
20
+ import 'package:tmail_ui_user/main/utils/app_config.dart' ;
20
21
import 'package:web_socket_channel/web_socket_channel.dart' ;
21
22
22
23
class WebSocketController extends PushBaseController {
@@ -79,7 +80,9 @@ class WebSocketController extends PushBaseController {
79
80
_retryRemained = 3 ;
80
81
_webSocketChannel = success.webSocketChannel;
81
82
_enableWebSocketPush ();
82
- _pingWebSocket ();
83
+ if (AppConfig .isWebSocketEchoPingEnabled) {
84
+ _pingWebSocket ();
85
+ }
83
86
_listenToWebSocket ();
84
87
}
85
88
Original file line number Diff line number Diff line change @@ -68,4 +68,6 @@ class AppConfig {
68
68
static String get _platformEnv => dotenv.get ('PLATFORM' , fallback: 'other' );
69
69
70
70
static bool get isSaasPlatForm => _platformEnv.toLowerCase () == saasPlatform;
71
+
72
+ static bool get isWebSocketEchoPingEnabled => dotenv.get ('WS_ECHO_PING' , fallback: 'false' ) == 'true' ;
71
73
}
You can’t perform that action at this time.
0 commit comments