updateStyles method
Send style update
Implementation
void updateStyles(String selector, Map<String, String> styles) {
if (_clients.isEmpty) return;
final updateMessage = jsonEncode({
'type': 'style_update',
'timestamp': DateTime.now().millisecondsSinceEpoch,
'selector': selector,
'styles': styles,
});
_clients.removeWhere((client) {
try {
client.add(updateMessage);
return false;
} catch (e) {
print('❌ Failed to send style update to client: $e');
return true;
}
});
print('🔥 Style update sent for ${_clients.length} clients');
}