messageReceived method

void messageReceived(
  1. String messageRaw
)

Upon message received from the JS engine

Implementation

void messageReceived(String messageRaw) async{
  print("[NUIMiniProgramEngine] Received raw message: $messageRaw");
  final dataMessage = processEventMessage(messageRaw);
  if(dataMessage != null) {
    print("[NUIMiniProgramEngine] Process raw message successful");
    completeMessageInQueue(dataMessage);
    print("[NUIMiniProgramEngine] Completing message in queue for id: ${dataMessage.id}");
    final reply = await _redirectPlatformMessage(dataMessage);
    if(reply != null){
      print("[NUIMiniProgramEngine] Gotten a reply for this message of id: ${dataMessage.id}, resp: ${jsonEncode(reply)}");
      await _sendCrossEvent(reply);
      print("[NUIMiniProgramEngine] Reply sent back to sender");
    }
    else{
      print("[NUIMiniProgramEngine] No reply for this message of id: ${dataMessage.id}");
    }
  }
  else{
    print("[NUIMiniProgramEngine] Processed raw message returns null");
  }
}