multicast/broadcast support

This commit is contained in:
2025-10-15 15:22:51 +02:00
parent eb154802b4
commit c5264186f3
12 changed files with 712 additions and 116 deletions

View File

@ -7,34 +7,54 @@ part 'project.g.dart';
class Project {
final String id;
final String name;
final String ipAddress;
// Support for multiple IP addresses at project level
final List<String> ipAddresses;
// Broadcast mode flag for project
@JsonKey(defaultValue: false)
final bool isBroadcast;
final int port;
final List<UdpPackage> packages;
// Legacy field for backward compatibility
@JsonKey(includeFromJson: true, includeToJson: false)
final String? ipAddress;
Project({
required this.id,
required this.name,
required this.ipAddress,
List<String>? ipAddresses,
this.isBroadcast = false,
required this.port,
required this.packages,
});
this.ipAddress,
}) : ipAddresses = ipAddresses ?? (ipAddress != null ? [ipAddress] : ['127.0.0.1']);
factory Project.fromJson(Map<String, dynamic> json) =>
_$ProjectFromJson(json);
factory Project.fromJson(Map<String, dynamic> json) {
// Handle migration from old format
if (json.containsKey('ipAddress') && !json.containsKey('ipAddresses')) {
json['ipAddresses'] = [json['ipAddress']];
}
return _$ProjectFromJson(json);
}
Map<String, dynamic> toJson() => _$ProjectToJson(this);
Project copyWith({
String? id,
String? name,
String? ipAddress,
List<String>? ipAddresses,
bool? isBroadcast,
int? port,
List<UdpPackage>? packages,
}) {
return Project(
id: id ?? this.id,
name: name ?? this.name,
ipAddress: ipAddress ?? this.ipAddress,
ipAddresses: ipAddresses ?? this.ipAddresses,
isBroadcast: isBroadcast ?? this.isBroadcast,
port: port ?? this.port,
packages: packages ?? this.packages,
);