thisbounty / WebRTC-API

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

Heartbeat -- Create client endpoints #1

Closed thisbounty closed 7 years ago

thisbounty commented 7 years ago

Create properties for Call model: searcher:object caller_heartbeat: date searcher_heartbeat: date

In /call/connect, set call.searcher to logged in user.

Create /calls/heartbeat/:id/ remote method and function. On call, lookup logged in user id, and determine if user is caller or searcher using call.caller.id, or call.searcher.id. Update call.caller_heartbeat or call.searcher_heartbeat accordingly.

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.

thisbounty commented 7 years ago

I'm working on it:

https://github.com/thisbounty/WebRTC-API/commit/8ac4859f834f8d742b52eed0b722ddcf33f5d5ff

If anyone want's to take over, same pay.

Emkacf commented 7 years ago

Mine now :)