addConnectedDevice method

Device? addConnectedDevice(
  1. String endpointId
)

Adds a device in connectedDevices set, removing it from initiatedConnections set after.

Implementation

Device? addConnectedDevice(String endpointId) {
  Device? device = _findDevice(initiatedConnections, endpointId);
  if (device == null) {
    logger.e(
        "Could not find a initiated connection from endpointID $endpointId");
    return null;
  }

  connectedDevices.add(device);
  initiatedConnections.remove(device);

  if (device.isPendingConnection) {
    pendingAcceptConnections.remove(device);
  }

  return device;
}