findParty function

Future<PartySeat> findParty(
  1. Uri relay, {
  2. required String game,
  3. int size = 4,
  4. String terms = '',
  5. SimulationVersion? simulation,
  6. void left(
    1. int slot
    )?,
  7. Duration timeout = const Duration(seconds: 10),
})

Finds a party of size for game on the relay at relay — one still filling with strangers who asked for the same, or a new one — and answers with this machine's seat in it. The seat's code is the party's, for a friend to join by; its full completes when the last player arrives, which is when a game should start.

game keeps games apart: two games on one relay, or one game's circuits, never match each other's players. So do terms and simulation, as joinParty reads them: a match forms only between builds on the same simulation.

Implementation

Future<PartySeat> findParty(
  Uri relay, {
  required String game,
  int size = 4,
  String terms = '',
  SimulationVersion? simulation,
  void Function(int slot)? left,
  Duration timeout = const Duration(seconds: 10),
}) => _seat(
  relay.replace(
    pathSegments: const <String>['match'],
    queryParameters: <String, String>{
      'size': '$size',
      'game': game,
      if (terms.isNotEmpty) 'terms': terms,
      ..._versions(simulation),
    },
  ),
  left: left,
  timeout: timeout,
);