deserializePPT method

  1. @override
PPTPayload? deserializePPT(
  1. Uint8List binPayload
)
override

Converts a uint8 data into a PPT Payload Object

Implementation

@override
PPTPayload? deserializePPT(Uint8List binPayload) {
  List<dynamic>? arguments;
  Map<String, dynamic>? argumentsKeywords;

  Object? decodedObject = msgpack_dart.deserialize(binPayload);

  if (decodedObject is Map) {
    if (decodedObject['args'] != null && decodedObject['args'] is List) {
      arguments = decodedObject['args'] as List<dynamic>?;
    }

    if (decodedObject['kwargs'] != null && decodedObject['kwargs'] is Map) {
      argumentsKeywords = Map.castFrom<dynamic, dynamic, String, Object>(
          decodedObject['kwargs'] as Map<dynamic, dynamic>);
    }

    return PPTPayload(
        arguments: arguments, argumentsKeywords: argumentsKeywords);
  }

  _logger.shout('Could not deserialize the message: $binPayload');
  // TODO respond with an error
  return null;
}