handle method

Future<void> handle({
  1. Application? app,
  2. DeviceCommand? command,
  3. WebSocketCommunicator? comm,
})

Implementation

Future<void> handle({
  Application? app,
  DeviceCommand? command,
  WebSocketCommunicator? comm,
}) async {
  if (command is GoodbyeCommand) {
    if (command.complete == true) {
      comm!.close();

      app!.devices.removeWhere((_, value) => value == comm);
      app.drivers.removeWhere((_, value) => value == comm);

      app.sessions.removeWhere((_, session) {
        var result = false;

        if (session.device == comm || session.driver == comm) {
          result = true;
          _logger.info('[GOODBYE]: closing session for: $comm');
          session.close();
        }

        return result;
      });
    }
  }
}