phoneEvents method

  1. @override
Future<OryksaPhoneEventsPage> phoneEvents(
  1. String pairId, {
  2. int after = 0,
  3. Duration wait = const Duration(seconds: 25),
})
override

Waits up to wait for phone events newer than after (long-poll).

Implementation

@override
Future<OryksaPhoneEventsPage> phoneEvents(String pairId, {int after = 0, Duration wait = const Duration(seconds: 25)}) async {
  // The server holds the request for up to `wait` (at most 30 s): keep it well under the
  // client's time limit too.
  var secs = wait.inSeconds;
  final limit = client.timeout.inSeconds - 5;
  if (secs > limit) secs = limit;
  if (secs > 30) secs = 30;
  if (secs < 1) secs = 1;
  final j = await client.request('GET', '/client/tv/pair/${_p(pairId)}/events?after=$after&wait=$secs');
  return OryksaPhoneEventsPage.fromJson(j, after: after);
}