handle method

void handle()

Implementation

void handle() async {
  final serverId = messageMap["serverId"];

  if(!confirmToServerThatDataHasBeenReceived){
    implementation();
    return;
  }

  confirmReceiptToServer(serverId);

  final LastServerMessage? dataAlreadySentByServerBefore = lastMessagesFromServer.firstWhereOrNull((m) => m.serverId == serverId);
  if(dataAlreadySentByServerBefore != null){
    logger("handle, data already received: $serverId");
    dataAlreadySentByServerBefore.messageReceivedAtSinceEpoch = DateTime.now().millisecondsSinceEpoch;
    return;
  }

  lastMessagesFromServer.add(LastServerMessage(serverId));

  checkCleanOldMessagesFromServer();

  implementation();
}