Voice and Video Calls
Voice and video calls use LiveKit for WebRTC. The backend exposes api/Call for tokens and call lifecycle; the frontend uses the LiveKit client and SignalR for call signaling (initiate, accept, reject, end).
Overview
- Backend:
api/Call— get LiveKit token, initiate call, accept, reject, end. Call initiation is also signaled via SignalR so the callee receives an incoming-call event. - LiveKit: Room-based; each call has a room name. Direct calls use a room like
call_{callerId}_{receiverId}_{ticks}; group calls usegroupcall_{groupId}_{ticks}. - Push: When the callee's tab or app is in the background, they can receive Web Push or Expo Push for incoming calls (see Web Push and Expo Push).
API Endpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/Call/token | Get LiveKit token for a room (body: roomName, optional displayName, canPublish, canSubscribe) |
| POST | /api/Call/initiate | Initiate a call (body: receiverId, optional callType e.g. "video", isGroupCall); returns roomName, token, url |
| POST | /api/Call/accept | Accept an incoming call |
| POST | /api/Call/reject | Reject an incoming call |
| POST | /api/Call/end | End an active call |
Flow
- Caller: Call
POST /api/Call/initiatewithreceiverId(and optionallyisGroupCall,callType). Backend creates a room name and returns a LiveKit token and URL. - Signaling: Backend notifies the callee via SignalR (and optionally RabbitMQ for push). Callee sees incoming call UI.
- Callee: Accept →
POST /api/Call/accept; then frontend gets a token (e.g. via same initiate flow or a dedicated token endpoint) and joins the LiveKit room. - Both: Connect to LiveKit with the token and join the room for audio/video.
- End: Either party calls
POST /api/Call/end; UI and room are cleaned up.
Configuration
- LiveKit: Configure
LiveKit:Url,LiveKit:ApiKey,LiveKit:ApiSecretin the backend (e.g. appsettings or environment). Default dev URL isws://localhost:7880. - Frontend: LiveKit client and optional env (e.g. LiveKit URL) for the client SDK.
Related
- Messaging — Chat and SignalR (call signaling)
- Web Push and Expo Push — Incoming call notifications when app is in background