As a mqtt client connected to mosquitto is it possible to retrieve a list of client IDs who are also connected to the broker?
as @user1048839 says, use client's LWT
& online publish msg,
maintain client status on a custom topic.
subscript this topic & maintain client list self.
if pub retain
msg, once sub will get the client list.
official code not support online_list,
so I patched mosquitto 1.5.4, add 2 custom sys topic:
mosquitto_sub -i DDD -v -t '$SYS/broker/chen_list'
$SYS/broker/chen_list
0 - CLOUD0_19108
1 - EEE
2 - DDD
mosquitto_sub -i DDD -v -t '$SYS/broker/chen_state/#'
$SYS/broker/chen_state/DDD 1
$SYS/broker/chen_state/EEE 1
$SYS/broker/chen_state/CLOUD0_19108 1
$SYS/broker/chen_state/EEE 0
$SYS/broker/chen_state/EEE 1
// if pub retain
msg, sub this topic can get all clients online state (in payload).
test source code on github: