unpackResponse function
Implementation
Response unpackResponse(Uint8List data) {
final header = jsonDecode(splitMessageHeader(data));
final payload = splitMessagePayload(data);
final typeKey = header['type'] as String;
if (!_responseTypes.containsKey(typeKey)) {
throw StateError('Unknown response type: $typeKey');
}
// Delegate to the correct `unpack` function
return _responseTypes[typeKey]!(header, payload);
}