getEvents method

  1. @deprecated
Future<GetEventsResponse> getEvents({
  1. String? from,
  2. int? timeout,
})
inherited

This will listen for new events and return them to the caller. This will block until an event is received, or until the timeout is reached.

This endpoint was deprecated in r0 of this specification. Clients should instead call the /sync endpoint with a since parameter. See the migration guide.

from The token to stream from. This token is either from a previous request to this API or from the initial sync API.

timeout The maximum time in milliseconds to wait for an event.

Implementation

@deprecated
Future<GetEventsResponse> getEvents({String? from, int? timeout}) async {
  final requestUri = Uri(path: '_api/client/v3/events', queryParameters: {
    if (from != null) 'from': from,
    if (timeout != null) 'timeout': timeout.toString(),
  });
  final request = Request('GET', baseUri!.resolveUri(requestUri));
  request.headers['authorization'] = 'Bearer ${bearerToken!}';
  final response = await httpClient.send(request);
  final responseBody = await response.stream.toBytes();
  if (response.statusCode != 200) unexpectedResponse(response, responseBody);
  final responseString = utf8.decode(responseBody);
  final json = jsonDecode(responseString);
  return GetEventsResponse.fromJson(json as Map<String, Object?>);
}