Skip to content

Room Signaling

Room uses TiRTC command channel 0x2200 to carry JSON-RPC 2.0 room signaling. Signaling synchronizes room state and does not carry audio data.

Message Format

After the device calls TiRtcWhipConnect(peer_id, token) and the connection is ready, it should listen for room signaling sent by Room service.

Room service sends room events as JSON-RPC Notification messages without id. The device does not need to reply to these events:

json
{
  "jsonrpc": "2.0",
  "method": "room_snapshot",
  "params": {
    "room_id": "myapp:order-20260611-001",
    "participant_id": "device_device-001",
    "self": {
      "participant_id": "device_device-001",
      "device_id": "device-001"
    },
    "participants": [
      {
        "participant_id": "device_device-001",
        "device_id": "device-001",
        "state": "active",
        "mic_state": "on"
      }
    ]
  }
}

The device can send JSON-RPC Requests or Notifications to synchronize room state. A Request must include id, and Room service returns a Response with the same id. A Notification does not include id, and Room service does not return a response.

json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "set_mic_state",
  "params": {
    "mic_state": "off"
  }
}

Common fields:

FieldTypeRequiredMeaning
jsonrpcstringYesFixed value: 2.0.
methodstringRequired for Notification / RequestSignaling method name.
paramsobjectMethod-specificMethod parameters. Methods without parameters can omit this field.
idnumberRequired for Request, forbidden for NotificationRequest identifier. Events sent by Room service do not include this field.
resultobjectMethod-specific for successful ResponseSuccessful request result.
errorobjectRequired for failed ResponseJSON-RPC error object.

Methods

MethodDirectionTypeDescription
join_roomDevice → Room serviceRequestValidates identity and audio formats, then joins the room.
leave_roomDevice → Room serviceNotificationActively leaves the current session.
get_room_snapshotDevice → Room serviceRequest / NotificationActively requests the current room snapshot.
set_mic_stateDevice → Room serviceRequest / NotificationReports the local microphone state.
room_snapshotRoom service → DeviceNotificationSent with the current room snapshot after join_room succeeds.
participant_joinedRoom service → DeviceNotificationSent to other online devices after a new participant joins.
participant_leftRoom service → DeviceNotificationSent to other online devices after a participant leaves.
participant_mic_state_changedRoom service → DeviceNotificationSent to other online devices after a participant's microphone state changes.
room_closedDevice → Room service / Room service → DeviceNotificationDevice requests closing the whole room; Room service broadcasts it to room members when the room is closed.

join_room

Direction: Device → Room service. Type: Request. Send it within 10 seconds after TiRTC connects. It can succeed only once per connection.

json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "join_room",
  "params": {
    "room_id": "room-001",
    "device_id": "device-001",
    "input_audio": {"codec": "pcm", "sample_rate": 16000, "channels": 1},
    "output_audio": {"codec": "g711a", "sample_rate": 16000, "channels": 1}
  }
}

room_id and device_id must match the signed WHIP Token parameters. The codec and sample rate for input_audio and output_audio can be specified independently. Both directions support opus, pcm, g711a, and amr at sample rates of 8000 and 16000, with one channel. amr/8000/1 corresponds to AMR-NB, while amr/16000/1 corresponds to AMR-WB. A successful response contains session_id and the normalized input_audio and output_audio; the device must use the actual formats returned in the response.

The legacy start_session method is no longer supported. If the first business Request with an id after TiRTC connects is not join_room, Room service returns method_not_found and closes the connection. It also closes the connection if the device does not complete the join within 10 seconds.

leave_room

Direction: Device → Room service. Type: Notification. When actively leaving, send it before closing the media connection.

json
{
  "jsonrpc": "2.0",
  "method": "leave_room"
}

leave_room takes no parameters and must not include id. Room service immediately removes the current participant, closes the current session, and sends participant_left to other online devices. If id is present, Room service returns invalid_request and does not leave the room.

Room service also performs fallback cleanup when the device disconnects or calls DELETE session. Normal leave flows should send leave_room first.

get_room_snapshot

Direction: Device → Room service.

Type: Request or Notification.

Trigger: sent when the device needs to refresh its local participant list. Common cases include command-channel open, a missed initial snapshot, or local state realignment.

json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "get_room_snapshot",
  "params": {}
}

Fields:

FieldTypeRequiredMeaning
jsonrpcstringYesFixed value: 2.0.
idnumberRequired for Request; forbidden for NotificationRequest identifier. Omit it when sending a Notification.
methodstringYesFixed value: get_room_snapshot.
paramsobjectNoNo parameters currently. Omit it or pass an empty object.

After successful processing, Room service sends a room_snapshot Notification to the current device. If the device sends a Request with id, Room service also returns a JSON-RPC success or error Response.

set_mic_state

Direction: Device → Room service.

Type: Request or Notification.

Trigger: sent when the local microphone switch or speaking state changes. This signaling only synchronizes state. It does not directly control audio mixing; the device still controls local capture and uplink audio.

json
{
  "jsonrpc": "2.0",
  "method": "set_mic_state",
  "params": {
    "mic_state": "speaking"
  }
}

Fields:

FieldTypeRequiredMeaning
jsonrpcstringYesFixed value: 2.0.
idnumberRequired for Request; forbidden for NotificationRequest identifier. Omit it when sending a Notification.
methodstringYesFixed value: set_mic_state.
paramsobjectYesMicrophone state parameters.
params.mic_statestringYeson means on, speaking means on and currently speaking, and off means off.

After recording the state, Room service sends participant_mic_state_changed to other online devices. If the device sends a Request with id, the success response is:

json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "ok": true
  }
}

room_snapshot

Direction: Room service → Device.

Type: Notification.

Trigger: sent to the device after it connects and joins the room, carrying the current room snapshot.

json
{
  "jsonrpc": "2.0",
  "method": "room_snapshot",
  "params": {
    "room_id": "myapp:order-20260611-001",
    "participant_id": "device_device-001",
    "self": {
      "participant_id": "device_device-001",
      "device_id": "device-001"
    },
    "participants": [
      {
        "participant_id": "device_device-002",
        "device_id": "device-002",
        "state": "active",
        "mic_state": "on"
      }
    ]
  }
}

Fields:

FieldTypeRequiredMeaning
jsonrpcstringYesFixed value: 2.0.
methodstringYesFixed value: room_snapshot.
paramsobjectYesCurrent room snapshot parameters.
idnumberNoNotification messages do not include id.
params.room_idstringYesRoom ID.
params.participant_idstringYesParticipant ID of the device receiving this snapshot.
params.selfobjectYesInformation about the current device.
params.self.participant_idstringYesParticipant ID of the current device.
params.self.device_idstringYesCurrent device ID.
params.participantsarrayYesCurrent participant list in the room.
params.participants[].participant_idstringYesParticipant ID.
params.participants[].device_idstringYesDevice ID for this participant.
params.participants[].statestringYesParticipant state. Online participants currently use active.
params.participants[].mic_statestringYesParticipant microphone state: on, speaking, or off.

participant_joined

Direction: Room service → Device.

Type: Notification.

Trigger: sent to other online devices after a new participant has connected and joined the room.

json
{
  "jsonrpc": "2.0",
  "method": "participant_joined",
  "params": {
    "room_id": "myapp:order-20260611-001",
    "participant": {
      "participant_id": "device_device-002",
      "device_id": "device-002",
      "state": "active",
      "mic_state": "on"
    }
  }
}

Fields:

FieldTypeRequiredMeaning
jsonrpcstringYesFixed value: 2.0.
methodstringYesFixed value: participant_joined.
paramsobjectYesParameters for the newly joined participant.
idnumberNoNotification messages do not include id.
params.room_idstringYesRoom ID.
params.participantobjectYesInformation about the newly joined participant.
params.participant.participant_idstringYesParticipant ID of the newly joined member.
params.participant.device_idstringYesDevice ID of the newly joined member.
params.participant.statestringYesParticipant state. Online participants currently use active.
params.participant.mic_statestringYesMicrophone state of the newly joined member: on, speaking, or off.

participant_left

Direction: Room service → Device.

Type: Notification.

Trigger: sent to other online devices after a participant disconnects or leaves the room.

json
{
  "jsonrpc": "2.0",
  "method": "participant_left",
  "params": {
    "room_id": "myapp:order-20260611-001",
    "participant_id": "device_device-002"
  }
}

Fields:

FieldTypeRequiredMeaning
jsonrpcstringYesFixed value: 2.0.
methodstringYesFixed value: participant_left.
paramsobjectYesParameters for the participant that left.
idnumberNoNotification messages do not include id.
params.room_idstringYesRoom ID.
params.participant_idstringYesParticipant ID of the member that left.

participant_mic_state_changed

Direction: Room service → Device.

Type: Notification.

Trigger: sent to other online devices after a participant reports a microphone state change through set_mic_state.

json
{
  "jsonrpc": "2.0",
  "method": "participant_mic_state_changed",
  "params": {
    "room_id": "myapp:order-20260611-001",
    "participant_id": "device_device-002",
    "mic_state": "off"
  }
}

Fields:

FieldTypeRequiredMeaning
jsonrpcstringYesFixed value: 2.0.
methodstringYesFixed value: participant_mic_state_changed.
paramsobjectYesParticipant microphone state change parameters.
idnumberNoNotification messages do not include id.
params.room_idstringYesRoom ID.
params.participant_idstringYesParticipant ID of the member whose state changed.
params.mic_statestringYeson means on, speaking means on and currently speaking, and off means off.

room_closed

Direction: Device → Room service; Room service → Device.

Type: Notification.

Trigger: A device can send this notification to request closing the whole room when allowed by your business rules. Room service sends this notification to room members when the room is closed.

json
{
  "jsonrpc": "2.0",
  "method": "room_closed",
  "params": {
    "room_id": "myapp:order-20260611-001",
    "reason": "closed_by_service"
  }
}

Fields:

FieldTypeRequiredMeaning
jsonrpcstringYesFixed value: 2.0.
methodstringYesFixed value: room_closed.
paramsobjectYesRoom close parameters.
idnumberNoNotification messages do not include id.
params.room_idstringYesRoom ID.
params.reasonstringNoClose reason. If omitted, the device should only treat the room as closed.

Request And Response

The device must send join_room as a Request and can also send get_room_snapshot and set_mic_state as Requests. A Request with id receives a success or error Response. leave_room must be sent as a Notification without id and receives no response.

Request example:

json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "set_mic_state",
  "params": {
    "mic_state": "off"
  }
}

Request fields:

FieldTypeRequiredMeaning
jsonrpcstringYesFixed value: 2.0.
idnumberYesRequest identifier. Room service returns the same value in the response.
methodstringYesRequest method name. The public device Request methods are join_room, get_room_snapshot, and set_mic_state.
paramsobjectNoRequest parameters. Omit it or pass an empty object when there are no parameters.

Error Response example:

json
{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32601,
    "message": "method not found"
  }
}

Error Response fields:

FieldTypeRequiredMeaning
jsonrpcstringYesFixed value: 2.0.
idnumberYesThe matching Request id.
errorobjectYesError object.
error.codenumberYesError code.
error.messagestringYesError message.
resultobjectNoSuccessful response result. Error responses do not include this field.

Error Codes

Room service follows the JSON-RPC 2.0 error response format:

json
{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32601,
    "message": "method not found"
  }
}

Room service defines these standard error codes:

CodeNameDescription
-32700parse_errorJSON parsing failed.
-32600invalid_requestThe request is invalid.
-32601method_not_foundThe method does not exist or is not publicly available.
-32602invalid_paramsThe parameters are invalid.
-32603internal_errorAn internal error occurred.

Room service also defines these business error codes:

CodeNameDescription
-32001room_not_readyThe room session is not ready.
-32002participant_mismatchThe participant in signaling does not match the token.
-32003room_fullThe room participant limit was reached.
-32004permission_deniedThe operation is not allowed.

Handling Recommendations

  • After TiRTC TiRtcWhipConnect reports that the connection is ready, send join_room first. After it succeeds, listen for room_snapshot to initialize the local participant list. Send get_room_snapshot if the device needs to actively realign state.
  • Update local participant state after receiving participant_joined, participant_left, or participant_mic_state_changed.
  • Send set_mic_state when the local microphone switch or speaking state changes. This method only synchronizes state and does not replace local capture or uplink control.
  • When actively leaving, send a leave_room Notification before entering resource cleanup.
  • After receiving room_closed, stop playback and release local media resources immediately.

Room