Make requests on chromecast receiver shutdown event - chromecast

I'm developing a chromecast custom receiver, and I need to send a request to the server once the sender disconnects from receiver. When I use ios or android senders, I can see that the 'sender disconnect' event is triggered, but when I use the browser, that event is not triggered.
Because of that, I'm trying to use the 'shutdown' event, to send that request, once the sender is disconnected.
I tried to pass an 'async/await' function as callback to the shutdown event, and tried to force an 'await' on the request, but I get the ' Application should not send requests before the system is ready (they will be ignored)'
I also tried to use the window 'beforeunload' event, but with no success.
Is there any way to send a request, once the 'shutdown' event is triggered?
Cheers

For us the Dispatching Shutdown event occurred in both cases. Web and Mobile senders. So I'm not sure what's happening on your end but will definitely need more information regarding what you're doing in order to look further into it.
Anyhow, if you are setting addEventListeners on your end like this:
context.addEventListener(cast.framework.system.ShutdownEvent,
()=>{
console.log("ShutdownEvent Called");
});
context.addEventListener(cast.framework.system.SenderDisconnectedEvent,
()=>{
console.log("SenderDisconnectedEvent called");
});
Which will result in your calls not firing. You should instead be doing:
context.addEventListener(cast.framework.system.EventType.SHUTDOWN,
()=>{
console.log("ShutdownEvent Called");
});
context.addEventListener(cast.framework.system.EventType.SENDER_DISCONNECTED,
()=>{ console.log("SenderDisconnectedEvent called"); });
Here's the docs for their reference: https://developers.google.com/cast/docs/reference/web_receiver/cast.framework.system#.EventType

Related

Sinch Answered Call Event Callback (ACE) not called

I have added a Callback in Sinch portal to handle app to app calls via our server. When a call reaches the Sinch platform, the system makes a POST request to our server's calling callback URL i.e. Incoming Call Event Callback (ICE) called.
In response to ICE event our server response it as
{
"instructions": [],
"action": {
"name": "connectMXP"
}
}
and callee receive incoming call notification. When Callee pick-up call the call get connected but it doesn't request to our server's callback URL, i.e. ACE event not called.
But as given in Answered Call Event Callback (ACE)
This callback is made when the call is picked up by the callee (person receiving the call). It is a POST request to the specified calling callback URL.
So the question is what is required to receive ACE event callback, is there anything missing which should be enable at Sinch side or our server side in code ? Thanks !
App2APp calls only support ICE and DICE events. If you authorized the Caller to Call the Callee user, why do you need another event notification? As the calls are mostly peer2Peer based we currently do not support ACE or PIE events for Data calls.

Opentok Javascript: On self session/connection disconnect?

Opentok Javascript: On self session/connection disconnect?
I tried all the possible events, following code logs into the console when other deivces disconnects, but it never logs anything when it, itself, disconnects. Please point toward the even which is fired when the session is disconnected. I have tried sessionDisconnect as well without any luck.
this.session.on("connectionDestroyed", function(event) {
console.log(event);
});
Thanks in advance.
TokBox Developer Evangelist here.
The Session object dispatches SessionDisconnectEvent object when a session has disconnected. You mentioned that you tried, sessionDisconnect, but the event is actually sessionDisconnected.
You can listen to the event as such:
this.session.on("sessionDisconnected", function(event) {
console.log(event);
});
The connectionDestroyed event is dispatched when other connections leave the session.

How to get data from push notification response in ios by using Nativescript

How to retrieve and handle the payload data from the app in background & foreground in iOS. I got the push notifications working, but I don't know how to extract the response.
notificationCallbackIOS: (message: any) => {
console.log("Message : " + JSON.stringify(message));
}
"nativescript-push-notifications": "^1.1.3"
This callback is not working. I am unable to extract the payload data like action, title.
You could try to use this plugin https://github.com/EddyVerbruggen/nativescript-local-notifications
it has a addOnMessageReceivedCallback event for listening for incoming notifications. I also used it on my app that i'm developing now. Even its for local notification, it also listens for remote notification you can call it on your app.component.ts.

SocketIO - Does a browser refresh cause "on disconnect" to fire?

I'm using SocketIO and I need to disconnect a socket on the server side if the user presses refresh. I've tried implementing this like so:
io.on('disconnect', function(socket) {
socket.close();
})
But the disconnect event isn't firing. Is this intended behaviour and if so is there any way to disconnect a socket when a page is refreshed?
Yes, when implemented properly a browser refresh causes a disconnect event on the server. I just confirmed this with a simple test app.
The disconnect event is a socket event, not an io event. So, you need to register for it on the socket, not at the io level.
This is my event handler that works just fine on my test server:
io.on('connection', function(socket) {
socket.on('disconnect', function() {
console.log("disconnect: ", socket.id);
});
});
FYI, you do not need to close the socket yourself. That will happen automatically as all webSocket/socket.io connections are automatically closed whenever a page is refreshed or navigated away from.

DevExpress Aspxcallbackpanel Client Side Timeout?

I've read plenty about how to handle Server-Side timeouts & errors during a Callback...
but what about Client Side timeouts?
here's the example.
Guy fills out a web form. Hits submit & the ASPXCallbackPanel does a PerformCallback.
But right then... his internet drops or his router burps.
In my app, the Callback panel never returns control back to the Webpage.. and the callback never completes.
Anybody know a Timeout settings on the Client side? or a way to abort a callback through Javascript?
thanks
If I were you, I would start a timer everytime a callback is sent to the server and refresh the page when the timer ticks. If the callback returns earlier, the timer should be stopped. This can be easily done using the ASPxGlobalEvents control.

Resources