getChannelMaxFetchedSequenceId method

  1. @override
Future<int> getChannelMaxFetchedSequenceId(
  1. String channel
)

Returns the highest sequence_id currently stored for the specified channel.

This value is passed to the fetch API call to fetch only the delta of messages that occurred while the client was offline or disconnected.

Implementation

@override
Future<int> getChannelMaxFetchedSequenceId(String channel) async {
  final result = await _db.rawQuery(
    'SELECT MAX(${Broadcast.columnSequenceId}) as maxSeq '
    'FROM ${Broadcast.tableName} '
    'WHERE ${Broadcast.columnChannel} = ?',
    [channel],
  );
  if (result.isEmpty || result.first['maxSeq'] == null) return 0;
  return result.first['maxSeq'] as int;
}