getDriver method

  1. @protected
Driver getDriver({
  1. required Application app,
  2. required String driverId,
  3. required String driverName,
})

Helper function to get a Driver from the cache based on the driverId. A Driver will exist in the cache in the event it was previously connected and now attempting to reconnect.

The driverName is only used if this is a new connection from the Driver as opposed to a reconnection.

Implementation

@protected
Driver getDriver({
  required Application app,
  required String driverId,
  required String driverName,
}) {
  var result = app.drivers[driverId];

  if (result == null) {
    result = Driver(
      app: app,
      appIdentifier: app.appIdentifier,
      driverId: driverId,
      driverName: driverName,
    );
    app.drivers[driverId] = result;
  } else {
    logger.info('[REATTACHING DRIVER]: $driverId');
  }

  return result;
}