Solian/lib/models/packet.dart

28 lines
602 B
Dart
Raw Normal View History

2024-09-17 02:14:23 +08:00
import 'package:json_annotation/json_annotation.dart';
part 'packet.g.dart';
@JsonSerializable()
2024-05-18 18:17:16 +08:00
class NetworkPackage {
2024-09-16 19:50:49 +08:00
@JsonKey(name: 'w', defaultValue: 'unknown')
2024-05-18 18:17:16 +08:00
String method;
@JsonKey(name: 'e')
2024-08-23 22:43:04 +08:00
String? endpoint;
@JsonKey(name: 'm')
2024-05-18 18:17:16 +08:00
String? message;
@JsonKey(name: 'p')
2024-05-18 18:17:16 +08:00
Map<String, dynamic>? payload;
NetworkPackage({
required this.method,
2024-08-23 22:43:04 +08:00
this.endpoint,
2024-05-18 18:17:16 +08:00
this.message,
this.payload,
});
factory NetworkPackage.fromJson(Map<String, dynamic> json) =>
_$NetworkPackageFromJson(json);
2024-05-18 18:17:16 +08:00
Map<String, dynamic> toJson() => _$NetworkPackageToJson(this);
2024-05-18 18:17:16 +08:00
}