listSessions method

Future<List<Map<String, dynamic>>> listSessions()

Lists all active sessions registered on the server.

Implementation

Future<List<Map<String, dynamic>>> listSessions() async {
  try {
    final uri = Uri.parse('$_normalizedEndpoint/sessions');
    final res = await _transport('GET', uri);
    if (res.isOk) {
      final decoded = jsonDecode(res.body);
      if (decoded is List) {
        return decoded.cast<Map<String, dynamic>>();
      }
    }
    return const [];
  } catch (e, stack) {
    AgentationLogger.error('Failed to list sessions from $endpoint', e, stack);
    return const [];
  }
}