Skip to content

Commit

Permalink
Added presences to match
Browse files Browse the repository at this point in the history
Closed #59
  • Loading branch information
obrunsmann committed Mar 3, 2023
1 parent 5c8e99c commit 4a53dc7
Show file tree
Hide file tree
Showing 7 changed files with 543 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* Added creating a match by match name
* Added missing `vars` to session model
* Added `presences` to match

## 1.0.0-dev.5

Expand Down
18 changes: 16 additions & 2 deletions lib/src/models/match.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,36 @@ class Match with _$Match {
String? handlerName,
}) = _Match;

factory Match.realtime({
required String matchId,
required bool authoritative,
required String label,
required int size,
int? tickRate,
String? handlerName,
required List<UserPresence> presences,
}) = RealtimeMatch;

factory Match.fromJson(Map<String, Object?> json) => _$MatchFromJson(json);

factory Match.fromDto(api.Match dto) => Match(
factory Match.fromDto(api.Match dto) => Match.realtime(
matchId: dto.matchId,
authoritative: dto.authoritative,
handlerName: dto.handlerName,
label: dto.label.value,
size: dto.size,
tickRate: dto.tickRate,
presences: [],
);

factory Match.fromRtpb(rtpb.Match dto) => Match(
factory Match.fromRtpb(rtpb.Match dto) => Match.realtime(
matchId: dto.matchId,
authoritative: dto.authoritative,
label: dto.label.value,
size: dto.size,
presences: dto.presences
.map((e) => UserPresence.fromDto(e))
.toList(growable: false),
);
}

Expand Down
Loading

0 comments on commit 4a53dc7

Please sign in to comment.