2

i have this JS function call:

 this.customMessageBus = castReceiverManager.getCastMessageBus('urn:x-cast:mycastapp', cast.receiver.CastMessageBus.MessageType.JSON);

var errorMessage = {
                    action: 'ERROR_MESSAGE',
                    errorCode: 'code',
                    errorMessage: 'sometext'
                };

this.customMessageBus.broadcast(errorMessage);

in trying to write the corrispective in DART:

this.customMessageBus = castReceiverManager.callMethod("getCastMessageBus",
    [
      'urn:x-cast:mycastapp',
      'cast.receiver.CastMessageBus.MessageType.JSON'
    ]);
this.customMessageBus.callMethod("broadcast", ['{
                        action: 'ERROR_MESSAGE',
                        errorCode: 'code',
                        errorMessage: 'sometext'
                    }']);

But i take this exception:

EXCEPTION: Error: Unexpected message type for JSON serialization in [null]

The MessageBus component is documented at https://developers.google.com/cast/docs/reference/receiver/cast.receiver.CastMessageBus#constructor_1

Andrea Bozza
  • 1,374
  • 2
  • 12
  • 31

1 Answers1

0

Without knowing anything about the API, in the JS example you're passing a Map/Object, and in Dart you're passing a string. What happens if you pass it a Dart Map instead? Or if that doesn't work, you could try constructing a JS Object with the appropriate fields and passing that.

Alan Knight
  • 2,759
  • 1
  • 15
  • 13