sendMessage method

void sendMessage(
  1. Message message
)

Sends a message to all connected devices.

This also ensures that only the correct messages get sent to each device.

Implementation

void sendMessage(Message message) {
  for (final device in devices.values) {
    final thisDeviceAccepts = getCommandName(device.device);
    if (message.messageName != thisDeviceAccepts) return;
  	device.sendMessage(message);
  }
}