-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TF-3157 Update web socket with background service worker
TF-3157 Stub BroadcastChannel for mobile build
- Loading branch information
1 parent
c4d0c27
commit 7d59982
Showing
16 changed files
with
414 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
lib/features/push_notification/data/model/connect_web_socket_message.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import 'package:equatable/equatable.dart'; | ||
import 'package:json_annotation/json_annotation.dart'; | ||
import 'package:tmail_ui_user/features/push_notification/domain/model/web_socket_action.dart'; | ||
|
||
part 'connect_web_socket_message.g.dart'; | ||
|
||
@JsonSerializable() | ||
class ConnectWebSocketMessage with EquatableMixin { | ||
@JsonKey(name: 'action') | ||
final WebSocketAction webSocketAction; | ||
@JsonKey(name: 'url') | ||
final String webSocketUrl; | ||
@JsonKey(name: 'ticket') | ||
final String webSocketTicket; | ||
|
||
ConnectWebSocketMessage({ | ||
required this.webSocketAction, | ||
required this.webSocketUrl, | ||
required this.webSocketTicket, | ||
}); | ||
|
||
factory ConnectWebSocketMessage.fromJson(Map<String, dynamic> json) | ||
=> _$ConnectWebSocketMessageFromJson(json); | ||
Map<String, dynamic> toJson() => _$ConnectWebSocketMessageToJson(this); | ||
|
||
@override | ||
List<Object?> get props => [webSocketAction, webSocketUrl, webSocketTicket]; | ||
} |
31 changes: 31 additions & 0 deletions
31
lib/features/push_notification/data/model/web_socket_echo.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'package:json_annotation/json_annotation.dart'; | ||
|
||
part 'web_socket_echo.g.dart'; | ||
|
||
@JsonSerializable(includeIfNull: false) | ||
class WebSocketEcho { | ||
@JsonKey(name: '@type') | ||
final String? type; | ||
final String? requestId; | ||
final List<List<dynamic>>? methodResponses; | ||
|
||
WebSocketEcho({ | ||
this.type, | ||
this.requestId, | ||
this.methodResponses, | ||
}); | ||
|
||
factory WebSocketEcho.fromJson(Map<String, dynamic> json) => _$WebSocketEchoFromJson(json); | ||
|
||
Map<String, dynamic> toJson() => _$WebSocketEchoToJson(this); | ||
|
||
static bool isValid(Map<String, dynamic> json) { | ||
try { | ||
final webSocketEcho = WebSocketEcho.fromJson(json); | ||
final listResponses = webSocketEcho.methodResponses?.firstOrNull; | ||
return listResponses?.contains('Core/echo') ?? false; | ||
} catch (_) { | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
lib/features/push_notification/domain/model/web_socket_action.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
enum WebSocketAction {connect, disconnect} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.