PICO Platform Unity SDK
All Classes Namespaces Functions Variables Enumerations Enumerator Properties Modules Pages
RtcService Class Reference

Public Member Functions

delegate int ProcessAudioFrameFunction (RtcAudioFrame frame)
 

Static Public Member Functions

static RtcEngineInitResult InitRtcEngine ()
 Initializes the RTC engine. More...
 
static Task< string > GetToken (string roomId, string userId, int ttl, Dictionary< RtcPrivilege, int > privileges)
 Gets the token required by JoinRoom. More...
 
static int JoinRoom (string roomId, string userId, string token, RtcRoomProfileType roomProfileType, bool isAutoSubscribeAudio)
 Joins a user to a specified room. More...
 
static int JoinRoom2 (RtcRoomOptions joinRoomOptions, bool leaveIfInRoom=true)
 Joins a user to a room. More...
 
static int JoinRoomWithRetry (string roomId, string userId, string token, RtcRoomProfileType roomProfileType, bool isAutoSubscribeAudio)
 Leaves a room and retries to join it when the previous request fails and returns error code -2 (the user is already in this room). More...
 
static int LeaveRoom (string roomId)
 Leaves a specified room. More...
 
static void SetAudioPlaybackDevice (RtcAudioPlaybackDevice device)
 Sets the audio playback device. More...
 
static void RoomPauseAllSubscribedStream (string roomId)
 Unsubscribing from all the audio streams of a room, thereby making the local user unable to hear anything from the room. More...
 
static void RoomResumeAllSubscribedStream (string roomId)
 Resubscribing to all the audio streams of a room, thereby making the local user hear the voice from every in-room user. More...
 
static void RegisterLocalAudioProcessor (ProcessAudioFrameFunction processor, RtcAudioChannel channel, RtcAudioSampleRate sampleRate)
 Register local audio processor. You can use this function to modify the recorded audio. More...
 
static void EnableAudioPropertiesReport (int interval)
 Enables audio properties report. Once enabled, you will regularly receive audio report data. More...
 
static void PublishRoom (string roomId)
 Publishes the local audio stream to a room, thereby making the local user's voice heard by other in-room users. More...
 
static void UnPublishRoom (string roomId)
 Stops publishing the local audio stream to a room, so other in-room users are unable to hear the local user's voice. More...
 
static void DestroyRoom (string roomId)
 Destroys a specified room. The resources occupied by the room will be released after destruction. More...
 
static void StartAudioCapture ()
 Starts audio capture via the microphone.
 
static void StopAudioCapture ()
 Stops audio capture.
 
static void SetCaptureVolume (int volume)
 Sets the volume of the captured audio. More...
 
static void SetPlaybackVolume (int volume)
 Sets the playback volume. More...
 
static void SetEarMonitorMode (RtcEarMonitorMode mode)
 Switches the in-ear monitoring mode on/off. Once the in-ear monitoring mode is enabled, one can hear their own voice. More...
 
static void SetEarMonitorVolume (int volume)
 Sets the volume for in-ear monitoring. More...
 
static void MuteLocalAudio (RtcMuteState rtcMuteState)
 Mutes local audio to make one's voice unable to be heard by other in-room users. More...
 
static void UpdateToken (string roomId, string token)
 Updates the token in a room. More...
 
static void SetAudioScenario (RtcAudioScenarioType scenarioType)
 Sets the audio scenario. More...
 
static void RoomSetRemoteAudioPlaybackVolume (string roomId, string userId, int volume)
 Sets the volume for a remote user in a room. More...
 
static void RoomSubscribeStream (string roomId, string userId)
 Subscribes to the audio stream of a specific user in a room. More...
 
static void RoomUnSubscribeStream (string roomId, string userId)
 Unsubscribes from the audio stream of a specific user in a room. More...
 
static long SendRoomBinaryMessage (string roomId, byte[] message)
 Sends a binary message to a room. All in-room users will receive this message. More...
 
static long SendRoomMessage (string roomId, string message)
 Sends a text message to a room. All in-room users will receive this message. More...
 
static long SendUserBinaryMessage (string roomId, string userId, byte[] message)
 Sends a binary message to a user. Only the user can receive this message. More...
 
static long SendUserMessage (string roomId, string userId, string message)
 Sends a text message to a user. Only the user can receive this message. The message's bytes size shouldn't be greater than 64kB. More...
 
static int SendStreamSyncInfo (byte[] data, int repeatCount)
 Sends stream sync info. The sync info data will be sent in the same packet with the audio data. Users who subscribe to this audio stream will receive the stream sync info message. More...
 
static void SetOnTokenWillExpire (Message< string >.Handler handler)
 Sets the callback to get notified when the token is about to expire. More...
 
static void SetOnRoomMessageReceived (Message< RtcRoomMessageReceived >.Handler handler)
 Sets the callback to get notified when a to-room message is received. More...
 
static void SetOnRoomBinaryMessageReceived (Message< RtcBinaryMessageReceived >.Handler handler)
 Sets the callback to get notified when a to-room binary message is received. More...
 
static void SetOnUserMessageReceived (Message< RtcUserMessageReceived >.Handler handler)
 Sets the callback to get notified when a to-user message is received. More...
 
static void SetOnUserBinaryMessageReceived (Message< RtcBinaryMessageReceived >.Handler handler)
 Sets the callback to get notified when a to-user binary message is received. More...
 
static void SetOnRoomMessageSendResult (Message< RtcMessageSendResult >.Handler handler)
 Sets the callback to get whether the to-room message is sent successfully. More...
 
static void SetOnUserMessageSendResult (Message< RtcMessageSendResult >.Handler handler)
 Sets the callback to get whether the to-user message is sent successfully. More...
 
static void SetOnUserPublishStream (Message< RtcUserPublishInfo >.Handler handler)
 Sets the callback to get notified when a remote user publishes audio stream. More...
 
static void SetOnUserUnPublishStream (Message< RtcUserUnPublishInfo >.Handler handler)
 Sets the callback to get notified when a remote user cancels publishing audio stream. More...
 
static void SetOnStreamSyncInfoReceived (Message< RtcStreamSyncInfo >.Handler handler)
 Sets the callback to get notified when the stream sync info is received. More...
 
static void SetOnJoinRoomResultCallback (Message< RtcJoinRoomResult >.Handler handler)
 Sets the callback of JoinRoom to get RtcJoinRoomResult. More...
 
static void SetOnLeaveRoomResultCallback (Message< RtcLeaveRoomResult >.Handler handler)
 Sets the callback of LeaveRoom to get RtcLeaveRoomResult. More...
 
static void SetOnUserJoinRoomResultCallback (Message< RtcUserJoinInfo >.Handler handler)
 Sets the callback to get notified when someone has joined the room. More...
 
static void SetOnUserLeaveRoomResultCallback (Message< RtcUserLeaveInfo >.Handler handler)
 Sets the callback to get notified when someone has left the room. More...
 
static void SetOnRoomStatsCallback (Message< RtcRoomStats >.Handler handler)
 Sets the callback to regularly get room statistics after joining a room. More...
 
static void SetOnWarnCallback (Message< int >.Handler handler)
 Sets the callback to get warning messages from the RTC engine. The warning codes and descriptions are given below. More...
 
static void SetOnErrorCallback (Message< int >.Handler handler)
 Sets the callback to get error messages from the RTC engine. The error codes and descriptions are given below. More...
 
static void SetOnRoomWarnCallback (Message< RtcRoomWarn >.Handler handler)
 Sets the callback to get warning messages from the room. More...
 
static void SetOnRoomErrorCallback (Message< RtcRoomError >.Handler handler)
 Sets the callback to get error messages from the room. More...
 
static void SetOnConnectionStateChangeCallback (Message< RtcConnectionState >.Handler handler)
 Sets the callback to get notified when the state of the connection to the RTC server has changed. More...
 
static void SetOnUserMuteAudio (Message< RtcMuteInfo >.Handler handler)
 Sets the callback to get notified when the user has muted local audio. More...
 
static void SetOnUserStartAudioCapture (Message< string >.Handler handler)
 Sets the callback to get notified when the user has started audio capture. More...
 
static void SetOnUserStopAudioCapture (Message< string >.Handler handler)
 Sets the callback to get notified when the user has stopped audio capture. More...
 
static void SetOnAudioPlaybackDeviceChange (Message< RtcAudioPlaybackDevice >.Handler handler)
 Sets the callback to get notified when the audio playback device has been changed. More...
 
static void SetOnLocalAudioPropertiesReport (Message< RtcLocalAudioPropertiesReport >.Handler handler)
 Sets the callback to receive local audio report. Rtc engine will call this callback periodically once you call EnableAudioPropertiesReport. More...
 
static void SetOnRemoteAudioPropertiesReport (Message< RtcRemoteAudioPropertiesReport >.Handler handler)
 Sets the callback to receive remote audio report. Rtc engine will call this callback periodically once you call EnableAudioPropertiesReport. More...
 

Detailed Description

Real-time communications (RTC) technology enables users in the same room to communicate with each other through voice chat.

RTC service uses a centralized communication structure instead of an end-to-end one. After users have joined a room and enabled voice chat, the microphone keeps capturing audio data from users and uploading the data to the RTC server. Then, the RTC server transmits the audio data to each client in the room, and the client broadcasts the audio data received.

Member Function Documentation

◆ InitRtcEngine()

static RtcEngineInitResult InitRtcEngine ( )
inlinestatic

Initializes the RTC engine.

Note
You should call this method before using the RTC service.
Returns
The status that indicates whether the initialization is successful.

◆ GetToken()

static Task< string > GetToken ( string  roomId,
string  userId,
int  ttl,
Dictionary< RtcPrivilege, int >  privileges 
)
inlinestatic

Gets the token required by JoinRoom.

Parameters
roomIdThe ID of the room that the token is for.
userIdThe ID of the user that the token is for.
ttlThe time-to-live (ttl) of the token. The unit is seconds. The user will be kicked out from the room after ttl seconds.
privilegesThe dictionary that maps privilege to ttl. The unit is seconds.

◆ JoinRoom()

static int JoinRoom ( string  roomId,
string  userId,
string  token,
RtcRoomProfileType  roomProfileType,
bool  isAutoSubscribeAudio 
)
inlinestatic

Joins a user to a specified room.

Note
  • If code 0 is returned, you should use SetOnJoinRoomResultCallback to handle the final join room result.
  • If a non-zero code is returned, you should call LeaveRoom firstly to join the room in the next time.
Parameters
roomIdThe ID of the room to join.
userIdThe ID of user.
tokenThe token required for joining the room. You can get the token by calling GetToken.
roomProfileTypeRoom type:
  • 0: communication room
  • 1: live broadcasting room
  • 2: game room
  • 3: cloud game room
  • 4: low-latency room
isAutoSubscribeAudioWhether to automatically subscribe to the audio in the room:
  • true: subscribe
  • false: do not subscribe
Returns
0 indicates success, and other codes indicate failure.
Code Description
0 Success.
-1 Invalid roomID or userId.
-2 The user is already in this room.
-3 The RTC engine is null. You should initialize the RTC engine before joining a room.
-4 Creating the room failed.

◆ JoinRoom2()

static int JoinRoom2 ( RtcRoomOptions  joinRoomOptions,
bool  leaveIfInRoom = true 
)
inlinestatic

Joins a user to a room.

Parameters
joinRoomOptionsThe options to join a room.
leaveIfInRoomRetry to join the room if the request returns error code -2 (the user is already in the room).
Returns
0 indicates success, and other codes indicate failure.
Code Description
0 Success.
-1 Invalid roomID or userId.
-2 The user is already in this room.
-3 The RTC engine is null. You should initialize the RTC engine before joining a room.
-4 Creating the room failed.

◆ JoinRoomWithRetry()

static int JoinRoomWithRetry ( string  roomId,
string  userId,
string  token,
RtcRoomProfileType  roomProfileType,
bool  isAutoSubscribeAudio 
)
inlinestatic

Leaves a room and retries to join it when the previous request fails and returns error code -2 (the user is already in this room).

Parameters
roomIdThe ID of the room to join.
userIdThe ID of user.
tokenThe token required for joining the room. You can get the token by calling GetToken.
roomProfileTypeRoom type:
  • 0: communication room
  • 1: live broadcasting room
  • 2: game room
  • 3: cloud game room
  • 4: low-latency room
isAutoSubscribeAudioWhether to automatically subscribe to the audio in the room:
  • true: subscribe
  • false: do not subscribe
Returns
0 indicates success, and other codes indicate failure.
Code Description
0 Success.
-1 Invalid roomID or userId.
-2 The user is already in this room.
-3 The RTC engine is null. You should initialize the RTC engine before joining a room.
-4 Creating the room failed.

◆ LeaveRoom()

static int LeaveRoom ( string  roomId)
inlinestatic

Leaves a specified room.

Parameters
roomIdThe ID of the room to leave.
Returns

0 indicates success, and other codes indicate failure.

Code Description
0 Success.
-1 The RTC engine is not initialized.
-2 The user is not in the room.

◆ SetAudioPlaybackDevice()

static void SetAudioPlaybackDevice ( RtcAudioPlaybackDevice  device)
inlinestatic

Sets the audio playback device.

Parameters
deviceThe device ID.

◆ RoomPauseAllSubscribedStream()

static void RoomPauseAllSubscribedStream ( string  roomId)
inlinestatic

Unsubscribing from all the audio streams of a room, thereby making the local user unable to hear anything from the room.

Parameters
roomIdThe ID of the room whose audio streams are to be unsubscribed from.

◆ RoomResumeAllSubscribedStream()

static void RoomResumeAllSubscribedStream ( string  roomId)
inlinestatic

Resubscribing to all the audio streams of a room, thereby making the local user hear the voice from every in-room user.

Parameters
roomIdThe ID of the room whose audio streams are to be resubscribed to.

◆ RegisterLocalAudioProcessor()

static void RegisterLocalAudioProcessor ( ProcessAudioFrameFunction  processor,
RtcAudioChannel  channel,
RtcAudioSampleRate  sampleRate 
)
inlinestatic

Register local audio processor. You can use this function to modify the recorded audio.

Parameters
processorThe processor function. If it returns 0,means the function didn't change the data. If its return value is negative integer, means the function encounters error. If its return value is positive integer, means the function handled successfully.
channelThe channel of the audio you want to process.
sampleRateThe sample rate of the audio you want to process.

◆ EnableAudioPropertiesReport()

static void EnableAudioPropertiesReport ( int  interval)
inlinestatic

Enables audio properties report. Once enabled, you will regularly receive audio report data.

Parameters
intervalThe interval (in milliseconds) between one report and the next. You can set this parameter to 0 or any negative integer to stop receiving audio properties report. For any integer between (0, 100), the SDK will regard it as invalid and automatically set this parameter to 100; any integer equal to or greater than 100 is valid.

◆ PublishRoom()

static void PublishRoom ( string  roomId)
inlinestatic

Publishes the local audio stream to a room, thereby making the local user's voice heard by other in-room users.

Note
  • A user can only publish the local audio stream to one room at the same time.
  • If a user wants to publish the local audio stream to another room, UnPublishRoom(oldRoomId) should be called first to stop publishing the local audio stream to the current room and then Publish(newRoomId) should be called.
Parameters
roomIdThe ID of the room that the local audio stream is published to.

◆ UnPublishRoom()

static void UnPublishRoom ( string  roomId)
inlinestatic

Stops publishing the local audio stream to a room, so other in-room users are unable to hear the local user's voice.

Parameters
roomIdThe ID of the room to stop publishing the local audio stream to.

◆ DestroyRoom()

static void DestroyRoom ( string  roomId)
inlinestatic

Destroys a specified room. The resources occupied by the room will be released after destruction.

Parameters
roomIdThe ID of the room to destroy.

◆ SetCaptureVolume()

static void SetCaptureVolume ( int  volume)
inlinestatic

Sets the volume of the captured audio.

Parameters
volumeThe target volume. The valid value ranges from 0 to 400. 100 indicates keeping the original volume.

◆ SetPlaybackVolume()

static void SetPlaybackVolume ( int  volume)
inlinestatic

Sets the playback volume.

Parameters
volumeThe target volume. The valid value ranges from 0 to 400. 100 indicates keeping the original volume.

◆ SetEarMonitorMode()

static void SetEarMonitorMode ( RtcEarMonitorMode  mode)
inlinestatic

Switches the in-ear monitoring mode on/off. Once the in-ear monitoring mode is enabled, one can hear their own voice.

Parameters
modeWhether to switch the in-ear monitoring mode on/off:
  • 0: off
  • 1: on

◆ SetEarMonitorVolume()

static void SetEarMonitorVolume ( int  volume)
inlinestatic

Sets the volume for in-ear monitoring.

Parameters
volumeThe target volume. The valid value range from 0 to 400.

◆ MuteLocalAudio()

static void MuteLocalAudio ( RtcMuteState  rtcMuteState)
inlinestatic

Mutes local audio to make one's voice unable to be heard by other in-room users.

Deprecated:
MuteLocalAudio() can be replaced by UnPublishRoom(string roomId)
Parameters
rtcMuteStateThe state of local audio:
  • 0: off
  • 1: on

◆ UpdateToken()

static void UpdateToken ( string  roomId,
string  token 
)
inlinestatic

Updates the token in a room.

When a token's ttl is about to expire, you will receive a notification through SetOnTokenWillExpire. If you still want to stay in the room, you should call GetToken to get a new token and call UpdateToken with the new token. If you don't update token timely,you will be kicked out from the room.

Parameters
roomIdThe ID of the room you are in.
tokenThe token to update.

◆ SetAudioScenario()

static void SetAudioScenario ( RtcAudioScenarioType  scenarioType)
inlinestatic

Sets the audio scenario.

Note
Different audio scenarios can impact the voice quality and how the earphones work.
Parameters
scenarioTypeThe audio scenario type:
  • 0: Music
  • 1: HighQualityCommunication
  • 2: Communication
  • 3: Media
  • 4: GameStreaming

◆ RoomSetRemoteAudioPlaybackVolume()

static void RoomSetRemoteAudioPlaybackVolume ( string  roomId,
string  userId,
int  volume 
)
inlinestatic

Sets the volume for a remote user in a room.

Parameters
roomIdThe ID of the room.
userIdThe ID of the remote user.
volumeThe volume to set for the remote user, which ranges from 0 to 400 and 100 indicates the default volume.

◆ RoomSubscribeStream()

static void RoomSubscribeStream ( string  roomId,
string  userId 
)
inlinestatic

Subscribes to the audio stream of a specific user in a room.

Parameters
roomIdThe ID of the room.
userIdThe ID of the user in the room.

◆ RoomUnSubscribeStream()

static void RoomUnSubscribeStream ( string  roomId,
string  userId 
)
inlinestatic

Unsubscribes from the audio stream of a specific user in a room.

Parameters
roomIdThe ID of the room.
userIdThe ID of the user in the room.

◆ SendRoomBinaryMessage()

static long SendRoomBinaryMessage ( string  roomId,
byte[]  message 
)
inlinestatic

Sends a binary message to a room. All in-room users will receive this message.

The message's bytes size shouldn't be greater than 64kB.

Parameters
roomIdThe ID of the room.
messageThe binary message to be sent.
Returns
A room message ID of the int64 type, which is automatically generated and incremented.

◆ SendRoomMessage()

static long SendRoomMessage ( string  roomId,
string  message 
)
inlinestatic

Sends a text message to a room. All in-room users will receive this message.

The message's bytes size shouldn't be greater than 64kB.

Parameters
roomIdThe ID of the room.
messageThe message to be sent.
Returns
A room message ID of the int64 type, which is automatically generated and incremented.

◆ SendUserBinaryMessage()

static long SendUserBinaryMessage ( string  roomId,
string  userId,
byte[]  message 
)
inlinestatic

Sends a binary message to a user. Only the user can receive this message.

The message's bytes size shouldn't be greater than 64kB.

Parameters
roomIdThe ID of the room the user is in.
userIdThe ID of the user the message is sent to.
messageThe message to be sent.
Returns
A user message ID of the int64 type, which is automatically generated and incremented.

◆ SendUserMessage()

static long SendUserMessage ( string  roomId,
string  userId,
string  message 
)
inlinestatic

Sends a text message to a user. Only the user can receive this message. The message's bytes size shouldn't be greater than 64kB.

Parameters
roomIdThe ID of the room the user is in.
userIdThe ID of the user the message is sent to.
messageThe message to be sent.
Returns
A user message ID of the int64 type, which is automatically generated and incremented.

◆ SendStreamSyncInfo()

static int SendStreamSyncInfo ( byte[]  data,
int  repeatCount 
)
inlinestatic

Sends stream sync info. The sync info data will be sent in the same packet with the audio data. Users who subscribe to this audio stream will receive the stream sync info message.

Parameters
dataThe stream sync info.
repeatCountThe stream sync info will be sent repeatedly for the times set in repeatCount. It's designed to avoid losing package and ensuring that the sync info can be sent successfully. However, if repeatCount is too large, it will cause the sync info to pile up in the queue. Setting this parameter to 0 is recommended.
Returns
Any code equal to or below 0 indicates success, and others codes indicate failure.
Code Description
>=0 Send successfully.Indicates the times sent successfully.
-1 Send Failed. Message length exceeded 255B
-2 Send Failed. The data is empty.
-3 Send Failed. Send sync info with a un-publish screen stream.
-4 Send Failed. Send sync info with a un-publish audio stream.

◆ SetOnTokenWillExpire()

static void SetOnTokenWillExpire ( Message< string >.Handler  handler)
inlinestatic

Sets the callback to get notified when the token is about to expire.

Note
The token will expire 30 seconds after you receive this notification.
  • If you still want to stay in the room, you can get a new token by calling UpdateToken.
  • If you do not update the token after receiving this notification, you will be kicked out of the room in 30 seconds.
Parameters
handlerThe callback function, the string in the message indicates the room ID.

◆ SetOnRoomMessageReceived()

static void SetOnRoomMessageReceived ( Message< RtcRoomMessageReceived >.Handler  handler)
inlinestatic

Sets the callback to get notified when a to-room message is received.

Parameters
handlerThe callback handler.

◆ SetOnRoomBinaryMessageReceived()

static void SetOnRoomBinaryMessageReceived ( Message< RtcBinaryMessageReceived >.Handler  handler)
inlinestatic

Sets the callback to get notified when a to-room binary message is received.

Parameters
handlerThe callback handler.

◆ SetOnUserMessageReceived()

static void SetOnUserMessageReceived ( Message< RtcUserMessageReceived >.Handler  handler)
inlinestatic

Sets the callback to get notified when a to-user message is received.

Parameters
handlerThe callback handler.

◆ SetOnUserBinaryMessageReceived()

static void SetOnUserBinaryMessageReceived ( Message< RtcBinaryMessageReceived >.Handler  handler)
inlinestatic

Sets the callback to get notified when a to-user binary message is received.

Parameters
handlerThe callback handler.

◆ SetOnRoomMessageSendResult()

static void SetOnRoomMessageSendResult ( Message< RtcMessageSendResult >.Handler  handler)
inlinestatic

Sets the callback to get whether the to-room message is sent successfully.

Parameters
handlerThe callback handler.

◆ SetOnUserMessageSendResult()

static void SetOnUserMessageSendResult ( Message< RtcMessageSendResult >.Handler  handler)
inlinestatic

Sets the callback to get whether the to-user message is sent successfully.

Parameters
handler

◆ SetOnUserPublishStream()

static void SetOnUserPublishStream ( Message< RtcUserPublishInfo >.Handler  handler)
inlinestatic

Sets the callback to get notified when a remote user publishes audio stream.

Parameters
handlerThe callback handler.

◆ SetOnUserUnPublishStream()

static void SetOnUserUnPublishStream ( Message< RtcUserUnPublishInfo >.Handler  handler)
inlinestatic

Sets the callback to get notified when a remote user cancels publishing audio stream.

Parameters
handlerThe callback handler.

◆ SetOnStreamSyncInfoReceived()

static void SetOnStreamSyncInfoReceived ( Message< RtcStreamSyncInfo >.Handler  handler)
inlinestatic

Sets the callback to get notified when the stream sync info is received.

Parameters
handlerThe callback handler.

◆ SetOnJoinRoomResultCallback()

static void SetOnJoinRoomResultCallback ( Message< RtcJoinRoomResult >.Handler  handler)
inlinestatic

Sets the callback of JoinRoom to get RtcJoinRoomResult.

Parameters
handlerThe callback handler.

◆ SetOnLeaveRoomResultCallback()

static void SetOnLeaveRoomResultCallback ( Message< RtcLeaveRoomResult >.Handler  handler)
inlinestatic

Sets the callback of LeaveRoom to get RtcLeaveRoomResult.

Parameters
handlerThe callback handler.

◆ SetOnUserJoinRoomResultCallback()

static void SetOnUserJoinRoomResultCallback ( Message< RtcUserJoinInfo >.Handler  handler)
inlinestatic

Sets the callback to get notified when someone has joined the room.

Parameters
handlerThe callback handler.

◆ SetOnUserLeaveRoomResultCallback()

static void SetOnUserLeaveRoomResultCallback ( Message< RtcUserLeaveInfo >.Handler  handler)
inlinestatic

Sets the callback to get notified when someone has left the room.

Parameters
handlerThe callback handler.

◆ SetOnRoomStatsCallback()

static void SetOnRoomStatsCallback ( Message< RtcRoomStats >.Handler  handler)
inlinestatic

Sets the callback to regularly get room statistics after joining a room.

Parameters
handlerThe callback handler.

◆ SetOnWarnCallback()

static void SetOnWarnCallback ( Message< int >.Handler  handler)
inlinestatic

Sets the callback to get warning messages from the RTC engine. The warning codes and descriptions are given below.

Warning Code Description
-2001 Joining the room failed.
-2002 Publishing audio stream failed.
-2003 Subscribing to the audio stream failed because the stream cannot be found.
-2004 Subscribing to the audio stream failed due to server error.
-2013 When the people count in the room exceeds 500, the client will not be informed of user join and leave info anymore.
-5001 The camera permission is missing.
-5002 The microphone permission is missing.
-5003 Starting the audio capture device failed.
-5004 Starting the audio playback device failed.
-5005 No available audio capture device.
-5006 No available audio playback device.
-5007 The audio capture device failed to capture valid audio data.
-5008 Invalid media device operation.
Parameters
handlerThe callback handler.

◆ SetOnErrorCallback()

static void SetOnErrorCallback ( Message< int >.Handler  handler)
inlinestatic

Sets the callback to get error messages from the RTC engine. The error codes and descriptions are given below.

Error Code Description
-1000 Invalid token.
-1001 Unknown error.
-1002 No permission to publish audio stream.
-1003 No permission to subscribe audio stream.
-1004 A user with the same user Id joined this room. You are kicked out of the room.
-1005 Incorrect configuration on the Developer Platform.
-1007 Invalid room id.
-1009 Token expired. You should get a new token and join the room.
-1010 Token is invalid when you call UpdateToken
-1011 The room is dismissed and all user is moved out from the room.
-1070 Subscribing to audio stream failed. Perhaps the number of subscribed audio streams has exceeded the limit.
Parameters
handlerThe callback handler.

◆ SetOnRoomWarnCallback()

static void SetOnRoomWarnCallback ( Message< RtcRoomWarn >.Handler  handler)
inlinestatic

Sets the callback to get warning messages from the room.

Parameters
handlerThe callback handler.

◆ SetOnRoomErrorCallback()

static void SetOnRoomErrorCallback ( Message< RtcRoomError >.Handler  handler)
inlinestatic

Sets the callback to get error messages from the room.

Parameters
handlerThe callback handler.

◆ SetOnConnectionStateChangeCallback()

static void SetOnConnectionStateChangeCallback ( Message< RtcConnectionState >.Handler  handler)
inlinestatic

Sets the callback to get notified when the state of the connection to the RTC server has changed.

Parameters
handlerThe callback handler.

◆ SetOnUserMuteAudio()

static void SetOnUserMuteAudio ( Message< RtcMuteInfo >.Handler  handler)
inlinestatic

Sets the callback to get notified when the user has muted local audio.

Parameters
handlerThe callback handler.

◆ SetOnUserStartAudioCapture()

static void SetOnUserStartAudioCapture ( Message< string >.Handler  handler)
inlinestatic

Sets the callback to get notified when the user has started audio capture.

When a remote user called StartAudioCapture,RTC engine will call this callback.

Parameters
handlerThe callback handler.

◆ SetOnUserStopAudioCapture()

static void SetOnUserStopAudioCapture ( Message< string >.Handler  handler)
inlinestatic

Sets the callback to get notified when the user has stopped audio capture.

When a remote user called StopAudioCapture,RTC engine will call this callback.

Parameters
handlerThe callback handler.

◆ SetOnAudioPlaybackDeviceChange()

static void SetOnAudioPlaybackDeviceChange ( Message< RtcAudioPlaybackDevice >.Handler  handler)
inlinestatic

Sets the callback to get notified when the audio playback device has been changed.

Parameters
handlerThe callback handler.

◆ SetOnLocalAudioPropertiesReport()

static void SetOnLocalAudioPropertiesReport ( Message< RtcLocalAudioPropertiesReport >.Handler  handler)
inlinestatic

Sets the callback to receive local audio report. Rtc engine will call this callback periodically once you call EnableAudioPropertiesReport.

Parameters
handlerThe callback handler.

◆ SetOnRemoteAudioPropertiesReport()

static void SetOnRemoteAudioPropertiesReport ( Message< RtcRemoteAudioPropertiesReport >.Handler  handler)
inlinestatic

Sets the callback to receive remote audio report. Rtc engine will call this callback periodically once you call EnableAudioPropertiesReport.

Parameters
handlerThe callback handler.