CAF Receiver, shutdown handling

橙三吉。 提交于 2019-12-11 06:38:39

问题


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)


回答1:


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




回答2:


Synthax with CAF Receiver:

context.addEventListener(cast.framework.system.EventType.SHUTDOWN,
      e => {
        console.log("Shutdown");
    });


来源:https://stackoverflow.com/questions/49812065/caf-receiver-shutdown-handling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!