setCallbackReceivedMessageForDevice method

void setCallbackReceivedMessageForDevice(
  1. String endpointId,
  2. dynamic callbackReceivedMessage(
    1. Device
    ), {
  3. String callbackName = "ConnectionsManager:receivedMessageForDevice",
})

Sets callbackReceivedMessage callback for a given device that executes every time a message is received from that device.

Implementation

void setCallbackReceivedMessageForDevice(
    String endpointId, Function(Device) callbackReceivedMessage,
    {String callbackName = "ConnectionsManager:receivedMessageForDevice"}) {
  Device? device = _findDevice(connectedDevices, endpointId);
  if (device == null) {
    logger.e(
        "Could not set callback for received message because device $endpointId is neither connected nor active");
    return;
  }

  device.setCallbackReceivedMessage(callbackName, callbackReceivedMessage);
}