chromecastgoogle-castcustom-receiver

CAF Receiver, shutdown handling


i'm trying to add logic to the shutdown event on my receiver app but every time the sender disconnects, debugger just closes and no logic is executed (like sending some HttpRequests). My piece of code:

this.context.addEventListener(
        cast.framework.system.ShutdownEvent,
        e => {
                this._sendStats();
        });

Also tried cast.framework.system.SHUTDOWN and cast.framework.system.SENDER_DISCONNECTED. Is there other way to get the expected result (executing logic on apps shutdown)


Solution

  • You need to use the event type: cast.framework.system.EventType.SHUTDOWN:

    https://developers.google.com/cast/docs/reference/caf_receiver/cast.framework.system#.EventType