From 38f4a5a8eed3e56b8d24b552d2057178f227ce2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20G=C3=B3rski?= Date: Wed, 8 Apr 2020 21:57:30 +0200 Subject: [PATCH] add undefined as valid senderId in sendCustomMessage method (#43729) --- types/chromecast-caf-receiver/cast.framework.d.ts | 4 ++-- .../chromecast-caf-receiver-tests.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/types/chromecast-caf-receiver/cast.framework.d.ts b/types/chromecast-caf-receiver/cast.framework.d.ts index f30ce78169..923c1c36b5 100644 --- a/types/chromecast-caf-receiver/cast.framework.d.ts +++ b/types/chromecast-caf-receiver/cast.framework.d.ts @@ -1204,9 +1204,9 @@ export class CastReceiverContext { removeEventListener(type: system.EventType, handler: EventHandler): void; /** - * Sends a message to a specific sender. + * Sends a message to a specific sender or broadcasts it to all connected senders (to broadcast pass undefined as a senderId). */ - sendCustomMessage(namespace: string, senderId: string, message: any): void; + sendCustomMessage(namespace: string, senderId: string | undefined, message: any): void; /** * This function should be called in response to the feedbackstarted event if the application diff --git a/types/chromecast-caf-receiver/chromecast-caf-receiver-tests.ts b/types/chromecast-caf-receiver/chromecast-caf-receiver-tests.ts index bff9e9d75f..736fce3537 100644 --- a/types/chromecast-caf-receiver/chromecast-caf-receiver-tests.ts +++ b/types/chromecast-caf-receiver/chromecast-caf-receiver-tests.ts @@ -144,6 +144,14 @@ cast.framework.CastReceiverContext.getInstance().addEventListener( () => '¡hola!', ); +// send custom message to specific sender +cast.framework.CastReceiverContext.getInstance() + .sendCustomMessage('custom-namespace', 'sender-id', {}); + +// broadcast custom message to all connected senders +cast.framework.CastReceiverContext.getInstance() + .sendCustomMessage('custom-namespace', undefined, {}); + const loadingError = new cast.framework.events.ErrorEvent(DetailedErrorCode.LOAD_FAILED, 'Loading failed!'); // PlayerManager message interceptors