pubsubNumSub method
Returns the number of subscribers for the specified channels.
Returns a Map where keys are the channel names
and values are the number of subscribers.
Implementation
@override
Future<Map<String, int>> pubsubNumSub(List<String> channels) async {
final command = ['PUBSUB', 'NUMSUB', ...channels];
// Returns a flat Array: [channel1, count1, channel2, count2, ...]
final response = await execute(command) as List<dynamic>?;
if (response == null || response.isEmpty) return {};
final map = <String, int>{};
for (var i = 0; i < response.length; i += 2) {
// Server returns channel as String, count as Integer
map[response[i] as String] = response[i + 1] as int;
}
return map;
}