updateStyles method

void updateStyles(
  1. String selector,
  2. Map<String, String> styles
)

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');
}