Calls
YACS supports voice and video calls over WebRTC, using PeerJS with the signalling server built into the API.
Call flow
- The caller starts a call with
POST /api/conversations/:conversation/call. The server creates acallmessage and rings the other participants (CallEvent.MAKEover Socket.IO, plus a push notification). - A call rings for up to 45 seconds. If the callee's device connects while it's still ringing, it receives the call right away.
- The callee answers (
CallEvent.ANSWER) or rejects (POST /api/calls/:message/reject). Users already on another call are reported as busy. - Either side hangs up with
CallEvent.DISCONNECT.
The call message is updated as the call progresses, so the conversation keeps a call history: completed, declined or missed, with duration.
While a call is active the app keeps the screen awake (Wake Lock API) and plays a ringtone for incoming calls.
ICE servers
The client fetches ICE servers from GET /api/calls/ice-servers before each call:
- Google public STUN servers are always included.
- If
TURN_URLSandTURN_SECRETare configured, a TURN entry is added with time-limited credentials: the username is<expiry-unix-time>:<user-id>and the credential isbase64(HMAC-SHA1(TURN_SECRET, username))— the coturn REST-API scheme.
The response is marked no-store so credentials are never cached.
See Self-hosting → TURN for setup.