add undefined as valid senderId in sendCustomMessage method (#43729)

This commit is contained in:
Artur Górski
2020-04-08 21:57:30 +02:00
committed by GitHub
parent 612eff867b
commit 38f4a5a8ee
2 changed files with 10 additions and 2 deletions

View File

@@ -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

View File

@@ -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