Skip to content

Voice

A voice channel lets people talk in real time. The OriginChats server keeps track of who is in each call and shares their peer IDs. It doesn’t carry any audio.

The server:

  • Keeps the list of people in each voice channel, with their mute state.
  • Shares each participant’s peer_id, the ID your peer-to-peer media service gave that connection.
  • Tells everyone who can view the channel when people join, leave, mute, or unmute.

Your client must:

  • Capture and play audio.
  • Connect to other participants through a peer-to-peer media service, using their peer_id values.
  • Stop sending audio when the user mutes. Muting only changes what the server tells others.

For browser clients, @originchats/voice does all of this, plus screen sharing and camera.

Join with voice_join, giving the channel and your peer_id:

{
"cmd": "voice_join",
"channel": "hangout",
"peer_id": "b7c1e0f2-peer"
}

The response lists the people already in the call, with their peer IDs, so you can connect to each one:

{
"cmd": "voice_join",
"channel": "hangout",
"peer_id": "b7c1e0f2-peer",
"participants": [
{ "username": "mist", "peer_id": "4a9d3c21-peer", "muted": false }
]
}

Joining needs the channel’s view rule. A connection can be in one voice channel at a time, so joining another channel leaves the first. A user can’t join the same channel from two devices at once.

Event Sent when Fields
voice_user_joined Someone joins. channel, user
voice_user_updated Someone mutes or unmutes. channel, user
voice_user_left Someone leaves or disconnects. channel, username

The user object has id, username, and muted. People in the call also get peer_id. People who can view the channel but aren’t in the call get the event without it.

To see a call without joining, use voice_state. Channel objects for voice channels also include a voice_state list of usernames and mute states.

A connection leaves the call when it sends voice_leave, joins another voice channel, or closes. Call state lives only in memory, so a server restart empties every call. After reconnecting, join again if the user was in a call.

voice_mute and voice_unmute change the mute state others see. A user in a timeout can mute and leave, but can’t join or unmute.

Two severed users don’t see each other in voice. See severed users for the details.