sendInstantUIUpdate method
Send instant UI update to all connected browsers
Implementation
void sendInstantUIUpdate(List<Map<String, dynamic>> changes) {
if (_clients.isEmpty) {
print('⚠️ No instant UI update clients connected');
return;
}
final updateMessage = jsonEncode({
'type': 'instant_update',
'timestamp': DateTime.now().millisecondsSinceEpoch,
'changes': changes,
});
_clients.removeWhere((client) {
try {
client.add(updateMessage);
return false;
} catch (e) {
print('❌ Failed to send instant UI update to client: $e');
return true;
}
});
print('⚡ Instant UI update sent to ${_clients.length} browsers');
}