thisbounty / WebRTC-API

Quickly create admin interfaces on a Loopback 2.x API
MIT License
0 stars 2 forks source link

Heartbeat -- setInterval #2

Closed thisbounty closed 7 years ago

thisbounty commented 7 years ago

Create an interval function. Read time from a config value. Try creating in server/server.js:

http://stackoverflow.com/questions/26902094/setinterval-in-nodejs

In interval function, need calls.find({"where":{"status":"Connected"}}, function(data){})

In the callback function above, need to check call.caller_heartbeat and call.searcher_heartbeat.

If either one is greater than config expiration time, disconnect the call. Make two functions, one for tokbox disconnect, which calls opentok platform to destroy the session, the other for call2search disconnect, which updates call.status to "Disconnected".

Background

Need to disconnect hanging calls. Cannot rely on client side calling a disconnect endpoint.

Idea is to run a cron job, and disconnect calls that expired.

To keep call from expiring, both web app and desktop clients will call a url periodically, perhaps every 30 seconds. Call ID will be passed to get parameter, and endpoint looks up logged in user id.

User id is matched to call.caller.id or call.searcher.id properties, and updates call.caller_heartbeat, call.searcher_heartbeat.

Then cron endpoint runs every 30 seconds, and disconnects calls with either heartbeat that's over a limit, like 45 seconds. Need to close tokbox session, set call.status='Disconnected'

Server side events update all connected desktops.

Emkacf commented 7 years ago

Mine