Reputation: 1601
I can see where you can get a presence event for a presence change using the javascript, Android, and iOS libraries, but what about a server? It would be nice if their was a place to specify a web hook that would be called whenever any of your clients changes their presence.
Ideally this would be universal for all sub-accounts as well and it could specify the sub-account in the web hook callback along with the client id and presence status.
Thanks!
Upvotes: 2
Views: 495
Reputation: 313
Maybe you can make a trick for that. But using a websocket tool such as Pusher.
When your twilio client is connected you can send an ajax to the server. The twilio client API has an event for that.
On the server side you can trigger an event with your websocket tool to different channels.
With the Twilio JS Client API you can set up a callback to be called with the user is ready:
Twilio.Device.ready(function(device) {
// The device is now ready
// Here you can add a call to a server side file by AJAX
// For example
$.ajax({url:'connected.php', data: {user_id:54}});
});
On connected.php you can use the Pusher Server API http://pusher.com/ to send a notification to different channels, for example, connected.php could looks like:
$pusher = new Pusher(APP_KEY, APP_SECRET, APP_ID);
$pusher->trigger(array('user1','user2','user3',...), 'my-event',
array('message' => 'User ' . $_GET['user_id'] . ' connected'));
This will trigger an event to user1, user2, user3, ... with the message 'User 54 connected'.
Remember that you should implement the Pusher Client API on parent page so the user can receive the event.
Let me know if you need a better explanation
Upvotes: 0
Reputation: 10366
Twilio evangelist here.
Unfortunately today we don't have a way to let you get presence notifications on the server.
Hope that helps.
Upvotes: 3