TF-3157 Update web socket with background service worker
TF-3157 Stub BroadcastChannel for mobile build
This commit is contained in:
@@ -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];
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user