Solian/lib/models/packet.dart

28 lines
558 B
Dart
Raw Normal View History

2024-05-18 10:17:16 +00:00
class NetworkPackage {
String method;
2024-08-23 14:43:04 +00:00
String? endpoint;
2024-05-18 10:17:16 +00:00
String? message;
Map<String, dynamic>? payload;
NetworkPackage({
required this.method,
2024-08-23 14:43:04 +00:00
this.endpoint,
2024-05-18 10:17:16 +00:00
this.message,
this.payload,
});
factory NetworkPackage.fromJson(Map<String, dynamic> json) => NetworkPackage(
method: json['w'],
2024-08-23 14:43:04 +00:00
endpoint: json['e'],
2024-05-18 10:17:16 +00:00
message: json['m'],
payload: json['p'],
);
Map<String, dynamic> toJson() => {
'w': method,
2024-08-23 14:43:04 +00:00
'e': endpoint,
2024-05-18 10:17:16 +00:00
'm': message,
'p': payload,
};
}