CloudHub Docs
Download Documents

RTC


CloudHubSDK Android

Channel event

onConnectionStateChanged

Occurs when the network connection state changes.

void onConnectionStateChanged(int state)

Parameters

ParametersDescription
stateThe current network connection state::
* CONNECTION_STATE_DISCONNECTED(1)
* CONNECTION_STATE_CONNECTING(2)
* CONNECTION_STATE_CONNECTED(3)
* CONNECTION_STATE_RECONNECTING(4)
* CONNECTION_STATE_FAILED(5)

Details

This callback is triggered when the network connection status changes, and informs the user of the current network connection status.

onJoinChannelSuccess

Occurs when the local user joins a specified channel.

The channel name assignment is based on channelName specified in the joinChannel method.

void onJoinChannelSuccess(String channelId,String uid)

Parameters

ParametersDescription
channelIdChannel id
uidIf the uid is not specified when joinChannel is called, the server automatically assigns a uid.

Details

This callback method indicates that the client has successfully joined the specified channel.

onRejoinChannelSuccess

Occurs when a user rejoins the channel after being disconnected due to network problems.

void onRejoinChannelSuccess(String channelId,String uid)

Parameters

ParametersDescription
channelIdchannelId
uidIf the uid is not specified when joinChannel is called, the server automatically assigns a uid.

Details

When a user loses connection with the server because of network problems, the SDK automatically tries to reconnect and triggers this callback upon reconnection.

onLeaveChannel

Occurs when a user leaves the channel.

void onLeaveChannel(Structs.RtcStats stats)

Parameters

ParametersDescription
statsChannel status

Details

When the user calls leaveChannel to leave the channel, the SDK will trigger the callback.

onClientRoleChanged

Occurs when the user role switches in a live streaming. For example, from a host to an audience or vice versa.

void onClientRoleChanged(int oldRole, int newRole)

Parameters

ParametersDescription
oldRoleThe role before switching, the value is as follows:

* CLIENT_ROLE_BROADCASTER(1), host;
* CLIENT_ROLE_AUDIENCE(2 ), audience
newRoleRole after switching, the value is the same as above

Details

In a live broadcast scenario, this callback is triggered when a local user calls setClientRole to switch roles after joining a channel, that is, when the host switches to the audience, or when the audience switches to the host.

onUserJoined

The remote user (communication scene)/host (live scene) joins the current channel and calls back.

void onUserJoined(String uid, String properties, boolean isHistory, String fromChannelId)

Parameters

ParametersDescription
uidID of the remote user/host who joined the channel. If uid is specified in joinChannel, the ID is returned here; otherwise, the ID automatically assigned by the SDK is used
propertiesThe user-defined properties. User-defined properties can be specified through the joinChannel and setProperty interfaces
isHistoryWhether the user joined the channel before the local user
fromChannelIdWhen a cross-channel media stream from another channel is forwarded to this channel, this parameter is the source channel ID of the forwarded media stream. In other cases, the parameter value is an empty string

Details

The callback will be triggered in the following situations:

Note:

In the live broadcast scene,

onUserLeft

The remote user (communication scene)/host (live scene) leaves the current channel and calls back.

void onUserLeft(String uid, int reason)

Parameters

ParametersDescription
uidID of the remote user/host who left the channel
reasonThe reason for the user to leave, with the following values:
1: The user called leaveChannel to leave the channel actively
2: The user failed to receive the other party’s data packet for a long time, and the line was timed out.
3 : User was kicked out of the channel
4: Because the same user id entered the channel and left the channel
5: Because the server actively closed the channel, all users were kicked out
6: The user role was switched from the host For the audience
0: Leaving the channel for unknown reason
8: The inter-room channel is actively closed
9: The inter-room channel is disconnected

Details

It prompts that a remote user/host has left the channel (or dropped). There are two reasons for the user to leave the channel, namely, normal leaving and timeout drop (more than 30 seconds can not communicate with the server normally).

onConnectionLost

Network connection lost callback.

void onConnectionLost()

Details

Occurs when the SDK cannot reconnect to CloudHub edge server 10 seconds after its connection to the server is interrupted.

onTokenWillExpire

The token is about to expire within 30 seconds.

void onTokenWillExpire()

Details

If the Token is specified when calling joinChannel, because the Token has a certain time limit, if the Token is about to expire during the call, the SDK will trigger the callback 30 seconds in advance to remind the application Update the token. When receiving the callback, the user needs to regenerate a new Token on the server, and then call renewToken to pass the newly generated Token to the SDK.

onRequestToken

Occurs when the token has expired.

void onRequestToken()

Details

After a token is specified when joining the channel, the token expires after a certain period of time, and a new token is required to reconnect to the server.

Once you receive this callback, generate a new token on your app server, and call renewToken to pass the new token to the SDK.

onLocalUserPermissionChanged

The local user’s publishing or subscribing authority has changed.

void onLocalUserPermissionChanged(int type, boolean hasPermission)

Parameters

ParametersDescription
typeThe changed permission type, the value is as follows:

* PERMISSION_TYPE_PUBLISH(1), release;
* PERMISSION_TYPE_SUBSCRIBE( 2), subscribe
hasPermissionIs there currently a permission specified by the type parameter

Details

You can change the publishing and subscribing permissions of any user in the channel through the back-end api. When a user’s publishing and subscription permissions change, the published audio and video stream will be interrupted immediately, and the local user will receive the onLocalUserPermissionChanged callback. If you lose the publishing authority, other people in the channel will not be able to receive the audio and video of this user; if you lose the subscription authority, this user will not be able to receive the audio and video of other people in the channel.

Note:

After regaining the publishing permission, if you want to publish your own audio and video immediately, you need to call publishStream again after receiving the onLocalUserPermissionChanged callback /#publishstream) method. When the subscription permission is regained, the subscription will continue automatically, and only need to respond to the following onRemoteAudioStateChanged and onRemoteVideoStateChanged ) Is fine.

onChannelForceClosed

The channel is closed by the server callback

void onChannelForceClosed(String channelId, int reason)

Parameters

ParametersDescription
channelIdchannel id
reasonThe reason the channel was closed, the value is as follows:

* CLOSE_CHANNEL_REASON_UNKNOWN(1), unknown reason
* CLOSE_CHANNEL_REASON_CLOSECHANNEL( 2), server call

Details

When the server actively closes a channel, the callback will be triggered.

Local media events

onLocalAudioStateChanged

Local audio status change callback.

void onLocalAudioStateChanged(int state, int error)

Parameters

ParametersDescription
stateThe new local audio status, the value is as follows:

* LOCAL_AUDIO_STREAM_STATE_STOPPED(0)
* LOCAL_AUDIO_STREAM_STATE_RECORDING(1)
* LOCAL_AUDIO_STREAM_STATE_ENCODING(2)
* LOCAL_AUDIO_STREAM_STATE_FAILED(3)
errorError code, the value is as follows:

* LOCAL_AUDIO_STREAM_ERROR_OK(0)
* LOCAL_AUDIO_STREAM_ERROR_FAILURE(1)
* LOCAL_AUDIO_STREAM_ERROR_DEVICE_NO_PERMISSION(2)
* LOCAL_AUDIO_STREAM_ERROR_DEVICE_BUSY(3)
* LOCAL_AUDIO_STREAM_ERROR_RECORD_FAILURE(4)
* LOCAL_AUDIO_STREAM_ERROR_ENCODE_FAILURE(5)
* LOCAL_AUDIO_STREAM_ERROR_MUTED(6)
* LOCAL_AUDIO_STREAM_ERROR_UNMUTED(7)

Details

When the local audio status changes (including the local microphone recording status and audio encoding status), the SDK will trigger this callback to report the current local audio status. When the local audio fails, this callback can help understand the current audio status and the cause of the failure.

onLocalVideoStateChanged

Local video status change callback.

void onLocalVideoStateChanged(int cameraId, int state, int error)

Parameters

ParametersDescription
cameraIdCamera ID
stateThe new local video state, the value is as follows:

* LOCAL_VIDEO_STREAM_STATE_STOPPED(0)
* LOCAL_VIDEO_STREAM_STATE_CAPTURING(1)
* LOCAL_VIDEO_STREAM_STATE_ENCODING(2)
* LOCAL_VIDEO_STREAM_STATE_FAILED.(3)
errorError code, the value is as follows:

* LOCAL_VIDEO_STREAM_ERROR_OK(0)
* LOCAL_VIDEO_STREAM_ERROR_FAILURE(1)
* LOCAL_VIDEO_STREAM_ERROR_DEVICE_NO_PERMISSION(2)
* LOCAL_VIDEO_STREAM_ERROR_CAPTURE_FAILURE(4)

Details

When the status of the local video changes, the SDK will trigger this callback to report the current local video status. When the local video fails, this callback can help understand the current video status and the cause of the failure.

onFirstLocalAudioFrame

Occurs when the first local audio frame is captured.

void onFirstLocalAudioFrame()

onFirstLocalVideoFrame

Occurs when the first local video frame is captured.

void onFirstLocalVideoFrame(int cameraId, int width, int height)

Parameters

ParametersDescription
cameraIdCamera ID
widthWidth (pixels) of the first local video frame.
heightHeight (pixels) of the first local video frame.

Details

This callback is triggered when the first frame of local video is displayed.

onLocalVideoSizeChange

The local video width and height have changed callback.

void onLocalVideoSizeChange(int cameraId, int width, int height)

Parameters

ParametersDescription
cameraIdCamera ID
widthNew video width
heightNew video height

onHookLocalVideoFrame

Local video original data frame callback.

void onHookLocalVideoFrame(String cameraId,VideoFrame frame)

Parameters

ParametersDescription
cameraIdCamera ID
frameOriginal video data frame

Remote media events

onRemoteAudioStateChanged

Occurs when the remote audio state changes.

void onRemoteAudioStateChanged(String uid, int state, int reason)

Parameters

ParametersDescription
uidUser uid of the remote audio stream
stateThe new audio stream state, the value is as follows:

* REMOTE_AUDIO_STATE_STOPPED(0)
* REMOTE_AUDIO_STATE_STARTING(1)
* REMOTE_AUDIO_STATE_DECODING(2)
* REMOTE_AUDIO_STATE_FROZEN(3)
* REMOTE_AUDIO_STATE_FAILED(4)
reasonThe reason for the change is as follows:

* REMOTE_AUDIO_REASON_INTERNAL(0)
* REMOTE_AUDIO_REASON_NETWORK_CONGESTION(1)
* REMOTE_AUDIO_REASON_NETWORK_RECOVERY(2)
* REMOTE_AUDIO_REASON_LOCAL_MUTED(3)
* REMOTE_AUDIO_REASON_LOCAL_UNMUTED(4)
* REMOTE_AUDIO_REASON_REMOTE_MUTED(5)
* REMOTE_AUDIO_REASON_REMOTE_UNMUTED(6)
* REMOTE_AUDIO_REASON_REMOTE_OFFLINE(7)

Details

When the remote user/host audio status changes, the SDK will trigger this callback to report the current remote audio stream status to the local user.

onRemoteVideoStateChanged

Occurs when the remote video state changes.

void onRemoteVideoStateChanged(String uid, int mediaType, String streamId, int state, int reason, String streamInfo)

Parameters

ParametersDescription
uidUser uid of the remote video stream
mediaTypeStream type, the values are as follows:

* MEDIA_TYPE_AUDIO_ONLY(1)
* MEDIA_TYPE_AUDIO_AND_VIDEO(3)
* MEDIA_TYPE_ONLINE_MOVIE_VIDEO(4)
* MEDIA_TYPE_OFFLINE_MOVIE_VIDEO(5)
* MEDIA_TYPE_SCREEN_VIDEO(6)
streamIdThe unique ID of this video stream in the channel. You need to pass in this ID when calling the subscription/playing/setting remote video stream method
stateThe new stream state, the value is as follows:

* REMOTE_VIDEO_STATE_STOPPED(0)
* REMOTE_VIDEO_STATE_STARTING(1)
* REMOTE_VIDEO_STATE_FROZEN(2)
* REMOTE_VIDEO_STATE_FAILED(3)
reasonThe reason for the change, the values are as follows:

* REMOTE_VIDEO_STATE_REASON_INTERNAL(0)
* REMOTE_VIDEO_STATE_REASON_NETWORK_CONGESTION(1)
* REMOTE_VIDEO_STATE_REASON_NETWORK_RECOVERY(2)
* REMOTE_VIDEO_STATE_REASON_LOCAL_MUTED(3)
* REMOTE_VIDEO_STATE_REASON_LOCAL_UNMUTED(4)
* REMOTE_VIDEO_STATE_REASON_REMOTE_MUTED(5)
* REMOTE_VIDEO_STATE_REASON_REMOTE_UNMUTED(6)
* REMOTE_VIDEO_STATE_REASON_REMOTE_OFFLINE(7)
* REMOTE_VIDEO_STATE_REASON_AUDIO_FALLBACK(8)
* REMOTE_VIDEO_STATE_REASON_AUDIO_FALLBACK_RECOVERY(9)
* REMOTE_VIDEO_STATE_REASON_ADD_REMOTESTREAM(10)
* REMOTE_VIDEO_STATE_REASON_REMOVE_REMOTESTREAM(11)
streamInfoUser-defined data (Json string format)

Details

When the remote user/host video status changes, the SDK will trigger this callback to report the current remote video stream status to the local user. Each user may have multiple video streams, and each video has its type (type). The streamID is the unique identifier of a video stream in the channel.

onFirstRemoteAudioFrame

Occurs when the first remote audio frame is received.

void onFirstRemoteAudioFrame(String uid)

Parameters

ParametersDescription
uidUser ID of the remote user.

onFirstRemoteVideoFrame

Occurs when the first remote video frame is decoded.

void onFirstRemoteVideoFrame(String uid, int mediaType, String streamId, int width, int height)

Parameters

ParametersDescription
uidUser uid of the remote video stream
mediaTypeVideo stream type, see onRemoteVideoStateChanged
streamIdThe unique ID of the video stream in the channel. When calling the subscription/playing/setting remote video stream method, you need to pass in this ID
widthThe width of the first video frame
heightThe height of the first frame of video

Details

After the first video frame from the remote end is received locally and successfully decoded, the callback will be triggered. There are two situations:

onRemoteVideoSizeChange

The width and height of the remote video stream have been changed and called back.

void onRemoteVideoSizeChange(String uid, int mediaType,String streamId,int width, int height)

Parameters

ParametersDescription
uidUser uid of the remote video stream
mediaTypeVideo stream type, see onRemoteVideoStateChanged
streamIdThe unique ID of the video stream in the channel. When calling the subscription/playing/setting remote video stream method, you need to pass in this ID
widthNew video width
heightNew video height

Statistics event

onRtcStats

Current call statistics.

void onRtcStats(Structs.RtcStats stats)

Parameters

ParametersDescription
statsCall statistics. See RtcStats for details

onNetworkQuality

The network uplink and downlink quality report callback.

void onNetworkQuality(String uid, int txQuality, int rxQuality)

Parameters

ParametersDescription
uiduser id
txQualitySend quality report, the value is as follows:

* QUALITY_UNKNOWN(0)
* QUALITY_EXCELLENT(1)
* QUALITY_GOOD(2)
* QUALITY_POOR(3)
* QUALITY_BAD(4)
* QUALITY_VBAD(5)
* QUALITY_DOWN(6)
* QUALITY_UNSUPPORTED(7)
* QUALITY_DETECTING(8)
rxQualityReceiving quality report, the value is the same as above

onLocalAudioStats

Local audio stream statistics callback.

void onLocalAudioStats(Structs.LocalAudioStats stats)

Parameters

ParametersDescription
statsLocal audio statistics. See LocalAudioStats for details

Details

This callback describes the statistics of the audio stream sent by the local device. The SDK triggers this callback every 2 seconds.

onLocalVideoStats

Local video stream statistics callback.

void onLocalVideoStats(Structs.LocalVideoStats stats)

Parameters

ParametersDescription
statsLocal video statistics. See LocalVideoStats for details

Details

This callback describes the statistics of the video stream sent by the local device. The SDK triggers this callback every 2 seconds.

onRemoteAudioStats

Call back the statistics of the remote audio stream during a call.

void onRemoteAudioStats(Structs.RemoteAudioStats stats)

Parameters

ParametersDescription
statsRemote audio statistics. See RemoteAudioStats for details

Details

This callback describes the end-to-end audio stream statistics of the remote user during a call, and is triggered every 2 seconds for each remote user/host. If there are multiple users/hosts at the remote site at the same time, this callback will be triggered multiple times every 2 seconds.

onRemoteVideoStats

void onRemoteVideoStats(Structs.RemoteVideoStats stats)

Parameters

ParametersDescription
statsRemote video statistics. See RemoteVideoStats for details

Details

This callback describes the end-to-end video stream statistics of the remote user during a call, and is triggered every 2 seconds for each remote user/host. If there are multiple users/hosts at the remote site at the same time, this callback will be triggered multiple times every 2 seconds.

Music file playback event

onMovieStateChanged

The local user’s music file playback status changes callback.

void onMovieStateChanged(String mediaFile, int state, int error)

Parameters

ParametersDescription
mediaFileThe file path passed in when calling startPlayingMovie
statePlay status, the value is as follows:

* MOVIE_STATE_PLAYING(710)
* MOVIE_STATE_PAUSED(711)
* MOVIE_STATE_STOPPED(713)
* MOVIE_STATE_FAILED(714)
* MOVIE_STATE_PLAYCOMPLETE(715)
errorError code, the value is as follows:

* MOVIE_ERROR_OK(0)
* MOVIE_ERROR_CAN_NOT_OPEN(701)
* MOVIE_ERROR_TOO_FREQUENT_CALL(702)
* MOVIE_ERROR_INTERRUPTED_EOF(703)

onMovieProgress

The playback progress of the local user’s music file is called back.

void onMovieProgress(String mediaFile, long pos, long total)

Parameters

ParametersDescription
mediaFileThe file path passed in when startPlayingMovie is called
posPlay progress (milliseconds)
totalTotal file duration (milliseconds)

Sound effect file playback event

onAudioEffectFinish

The local user’s sound effect file playback status changes callback.

void onAudioEffectFinish(int soundId)

Parameters

ParametersDescription
soundIdThe sound effect ID passed in at startEffect.

Cross-channel media stream forwarding event

onChannelMediaRelayStateChanged

Occurs when the state of the media stream relay changes.

void onChannelMediaRelayStateChanged(String channelId, int state, int error)

Parameters

ParametersDescription
channelIdTarget channel number. Specify when starting/update cross-room media stream forwarding
stateCurrent state

* RELAY_STATE_IDLE(0), SDK is initializing
* RELAY_STATE_CONNECTING(1),SDK is trying to connect across rooms
* RELAY_STATE_RUNNING(2), The host of the source channel successfully joined the target channel
* RELAY_STATE_FAILURE(3), An exception occurred, see error code for details
errorError code when forwarding error

* RELAY_ERROR_OK(0), everything is normal
* RELAY_ERROR_SERVER_ERROR_RESPONSE(1), The server responded with an error
* RELAY_ERROR_SERVER_NO_RESPONSE(2), No response from server
* RELAY_ERROR_NO_RESOURCE_AVAILABLE(3), Server resources are unavailable
* RELAY_ERROR_FAILED_JOIN_SRC(4), Failed to initiate forwarding request
* RELAY_ERROR_FAILED_JOIN_DEST(5), Failed to accept forwarding request
* RELAY_ERROR_FAILED_PACKET_RECEIVED_FROM_SRC(6), Server failed to receive media stream
* RELAY_ERROR_FAILED_PACKET_SENT_TO_DEST(7), Server failed to send media stream
* RELAY_ERROR_SERVER_CONNECTION_LOST(8),Poor network, disconnected
* RELAY_ERROR_INTERNAL_ERROR(9), internal error

Details

When the cross-channel media stream forwarding status changes, the SDK will trigger the callback and report the current forwarding status and related error information.

Volume indication event

onAudioVolumeIndication

Reports the volume information of users.

void onAudioVolumeIndication(String uid, int volume, int vad)

Parameters

ParametersDescription
uiduser uid
volumeVolume, 0~255
vadIs the user talking

Details

This callback is disabled by default. It can be turned on by the enableAudioVolumeIndication method; after it is turned on, the SDK will press the setting in the enableAudioVolumeIndication method regardless of whether someone is speaking in the channel. The time interval triggers the onAudioVolumeIndication callback.

onActiveSpeaker

Speaker volume reminder callback.

virtual void onActiveSpeaker(String uid)

Parameters

ParametersDescription
uidID of the most active remote user

Details After successfully calling enableAudioVolumeIndication, the SDK will continue to monitor the remote user with the loudest volume and count the number of times the user is judged to be the one with the loudest volume. In the current time period, the remote user with the most accumulated number of times is the most active user.

When the number of users in the channel is greater than or equal to 2 and there are active users, the SDK will trigger the callback and report the uid of the most active user.

Network test event before call

onLastmileQuality

Report the network quality of local users.

void onLastmileQuality(int quality)

Parameters

ParametersDescription
qualityThe network quality of the current local user. See onNetworkQuality() for details

onLastmileProbeResult

Report the results of the network test before the call.

void onLastmileProbeResult(Structs.LastmileProbeResult result)

Parameters

ParametersDescription
resultThe result of the network test before the call. See LastmileProbeResult for details

Original audio data event

onRecordAudioFrame

void onRecordAudioFrame(byte[] data, int sampleRate, int channels, int samples);

Set the format of the collected data callback.

Parameters

ParametersDescription
dataReceived data
sampleRatesample rate
channelsNumber of channels
samplesNumber of samples per channel

onPlaybackAudioFrame

void onPlaybackAudioFrame(byte[] data, int sampleRate, int channels, int samples);

Set the format of the playback data callback

Parameters

ParametersDescription
dataReceived data
sampleRatesample rate
channelsNumber of channels
samplesNumber of samples per channel

Content review event

onAuditAlertFromLocalVideo

Video violation callback

void onAuditAlertFromLocalVideo(String atTime,String channelId,String uid,String streamId,String jsonDesc)

Parameters

ParametersDescription
atTimeViolation time point
channelIdRoom number
uidUser Id
streamIdStream Id
jsonDescViolation Content

onAuditAlertFromLocalAudio

Audio violation callback

void onAuditAlertFromLocalAudio(String atTime,String channelId,String uid,String jsonDesc)

Parameters

ParametersDescription
atTimeViolation time point
channelIdRoom number
uidUser Id
jsonDescViolation content

onAuditAlertFromLocalChat

Chat violation callback

void onAuditAlertFromLocalChat(String atTime,String channelId,String uid,String jsonDesc)

Parameters

ParametersDescription
atTimeViolation time point
channelIdRoom number
uidUser Id
jsonDescViolation content

Record sound clip event

onVoiceClipFileReady

Record sound clip callback

public void onVoiceClipFileReady(String clipBaseName, String currentClipFileName, long clipTs)

Parameters

ParametersDescription
clipBaseNameSound clip basename
currentClipFileNameComplete sound clip name
clipTsMillisecond timestamp

Streaming news events

onStreamMessage

void onStreamMessage(String uid, byte[] message);

Receive callback of the other party’s data stream message.

This callback indicates that the local user has received the stream message sent by the remote user calling the sendStreamMessage method.

Parameters

ParametersDescription
uidUser ID
messagereceived data

Publish events remotely (only for manual subscription mode)

onUserPublished

The remote user starts to post audio and video callbacks.

void onUserPublished(String uid, int mediaType,String streamId)

Parameters

ParametersDescription
uidID of the user who posted the video stream
mediaTypeVideo stream type, see onRemoteVideoStateChanged
streamIdThe unique ID of the video stream in the channel. When calling the subscription/playing/setting remote video stream method, you need to pass in this ID

Details

When a user in the channel successfully publishes the audio and video stream, if the local automatic subscription is turned off (see setAutoSubscribe for details), you will receive the onUserPublished callback. At this time, if you decide to watch this person, you need to call subscribeStream, and you will receive onRemoteVideoStateChanged callback. If the automatic subscription is not turned off locally, you will directly receive the onRemoteVideoStateChanged callback. When a user in the channel successfully publishes the audio and video stream, if the local automatic subscription is turned off (see setAutoSubscribe for details), you will receive the onUserPublished callback. At this time, if you decide to watch this person, you need to call subscribeStream, and you will receive onRemoteVideoStateChanged callback. If the automatic subscription is not turned off locally, you will directly receive the onRemoteVideoStateChanged callback.

onUserUnPublished

The remote user stops publishing audio and video callbacks.

void onUserUnPublished(String uid, int mediaType,String streamId)

Parameters

ParametersDescription
uidID of the user who posted the video stream
mediaTypeVideo stream type, see onRemoteVideoStateChanged
streamIdThe unique ID of the video stream in the channel. When calling the subscription/playing/setting remote video stream method, you need to pass in this ID

Details

When a user in the channel stops the audio and video streaming, if the local automatic subscription is turned off (see setAutoSubscribe for details), the onUserUnPublished callback will be received. There is no need to actively call the unSubscribe method at this time.

Server recording event

onServerRecordStateChange

Callback when the recording status of the server changes.

void onServerRecordStateChange(int state, long startTS, long currTS, long pauseDuration, long recordDuration)

Parameters

ParametersDescription
stateThe current recording state. 0 has not started, 1 is recording, 2 is paused.
startTSStart time (milliseconds elapsed since 0:00 on January 1, 1970)
currTSCurrent server time (milliseconds elapsed since 0:00 on January 1, 1970)
pauseDurationThe total duration of the pause, in milliseconds.
recordDurationTotal recording duration (excluding pause time), milliseconds.

Advanced signaling event

onSetProperty

User-defined attribute change callback.

void onSetProperty(String uid, String fromId, String properties)

Parameters

ParametersDescription
uidUser uid whose attribute changed
fromIidUser uid who initiated the operation
propertiesThe changed properties, json string

Note

The local user will receive this callback only when the local user is within the notification range specified when calling setProperty (if not specified, everyone in the channel will be notified).

onChatMessageArrival

Chat message callback.

void onChatMessageArrival(String fromId, String textMsg, String extraData)

Parameters

ParametersDescription
fromIduid of the user who initiated the operation
textMsgMessage text content
extraDataAdditional data, may be empty

Note

The local user will receive this callback only when the local user is within the notification range specified when calling sendChatMsg (not specified, that means notifying everyone in the channel).

onPubMsg

Custom message publishing callback.

void onPubMsg(String msgId,
String msgName,
String fromId,
String toId,
String data,
String associatedUserId,
String associatedMsgId,
long ts,
long seq,
String extraData,
boolean isHistory)

Parameters

ParametersDescription
msgIdMessage id, which is the unique identifier of a message in the channel
msgNameMessage name
fromIdThe uid of the message sender
toIdThe target uid of the notification, if it is empty, notify everyone in the channel
dataMessage content. Must be a json string. Can be empty
associatedUserIdThe uid of the associated user, once a message is associated with a user, the message will be automatically deleted when the user logs out
associatedMsgIdThe id of the associated message. Once a message is associated with another message, the associated message will be deleted automatically when the associated message is deleted.
tsThe timestamp when the server last received the message
seqThe global sequence number of the message
extraDataReserved parameters
isHistoryIs the message sent before the local user enters the channel

Note

The local user will receive this callback only when the local user is within the notification range specified when calling pubMsg (if not specified, everyone in the channel will be notified).

onDelMsg

Custom message delete callback.

void onDelMsg(
String msgId,
String msgName,
String fromId,
String toId,
String associatedUserId,
String associatedMsgId,
long ts,
long seq,
String extraData
)

Parameters

ParametersDescription
msgIdMessage id, which is the unique identifier of a message in the channel
msgNameMessage name
fromIdThe uid of the message sender
toIdThe target uid of the notification, if it is empty, notify everyone in the channel
dataMessage content. Must be a json string. Can be empty
associatedUserIdThe uid of the associated user, once a message is associated with a user, the message will be automatically deleted when the user logs out
associatedMsgIdThe id of the associated message. Once a message is associated with another message, the associated message will be deleted automatically when the associated message is deleted.
tsThe timestamp when the server last received the message
seqThe global sequence number of the message
extraDataReserved parameters

Note

The local user will receive this callback only when the local user is within the notification range specified when calling delMsg (if not specified, everyone in the channel will be notified).

onLocalUserEvicted

The local user was kicked out of the room to call back.

void onLocalUserEvicted(int reason)

Parameters

ParametersDescription
reasonThe reason for being kicked. Filled in by the server, or passed in when calling evictUser

Details

When this callback is received, there may be two reasons:

Other events

onError

Reports an error during SDK runtime.

void onError(int err, String msg)

Parameters

ParametersDescription
errError code, the value is as follows:

* ERR_OK(0)
* ERR_FAILED(1)
* ERR_INVALID_ARGUMENT(2)
* ERR_NOT_READY(3)
* ERR_NOT_SUPPORTED(4)
* ERR_REFUSED(5)
* ERR_BUFFER_TOO_SMALL(6)
* ERR_NOT_INITIALIZED(7)
* ERR_JOIN_CHANNEL_REJECTED(17)
* ERR_LEAVE_CHANNEL_REJECTED(18)
* ERR_RESOURCE_LIMITED(22)
* ERR_INVALID_APP_ID(101)
*ERR_IN_BLACKLIST(104)
*ERR_ENTERPRISE_CONCURRENT_POINTS_EXCEED_LIMIT(107)
* ERR_TOKEN_EXPIRED(109)
* ERR_INVALID_TOKEN(110)
* ERR_NOT_IN_CHANNEL(113)
* ERR_PUBLISH_NOT_AUTHORIZED(501)
* ERR_PUBLISH_INTERNAL_SERVER_ERROR(502)
* ERR_SUBSCRIBE_NOT_AUTHORIZED(601)
* ERR_SUBSCRIBE_INTERNAL_SERVER_ERROR(602)
* ERR_MOVIE_ALREADY_PLAYING(701)
* ERR_MOVIE_ALREADY_PUBLISHING(702)
* ERR_UNKNOWN(-1)
msgError message prompt

Note

The occurrence of this callback indicates that an error (network or media related) occurred during SDK runtime. Normally, the error reported by the SDK means that the SDK cannot be automatically restored, and the app needs to intervene or prompt the user.

onServerTime

Server current time notification.

void onServerTime(long serverTime)

Parameters

ParametersDescription
serverTimeServer time, UTC