CloudHub JSSDK
- Overview
- CloudHubRTC
- CloudHubRTCObject
- Client
- ClientEvent
- ClientLiveTranscoding
- ClientChannelMediaRelayConfig
- Stream
- StreamEvent
- DeviceManager
- Constants
Client Event document
What it does: This callback notifies the App that a chat message has been received.
Base
app-exception
What it does: This callback notifies the App program of an exception.
Callback parameter evt structure:
{
errorinfo:"error info"
}
// Example:
client.on("app-exception", function (evt) {
console.error("app-exception", evt.errorinfo);
})
signal-connect-fail
What it does: This callback notification failed to establish a connection with the server.
Callback parameter evt structure:
{
errflag:"INVALID_ARG"
message:"channel or tokenOrKey is invalid param",
retryConnect: false
}
Note: The possible values for Errflag are as follows:
- “CHANNEL_NO_SPECIFICATION”: The parameter channel does not conform to the specification and contains unsupported characters. [Will not reconnect]
- “INVALID_ARG”: Invalid parameter. [Will not reconnect]
- “CLIENT_NOT_INIT”: Client is not initialized. [Will not reconnect]
- “EMPTY_SIGNAL_ADDR_LIST”: There is no connectable signaling server address. [Will not reconnect]
- “JOIN_CHANNEL_FAIL”: Failed to join the channel. [Will not reconnect]
- “CHANNEL_CONNECT_ERROR”: Disconnect with the signaling server. [Will be re-connected]
- “JOIN_AUTH_FAIL”: Joining channel verification rights failed. [Will not re-connect]
- “CHANNEL_MODE_MISMATCH”:The channel mode does not match. For example, the channel scene is a call scene (mode is live), but the live scene (mode is rtc) is transmitted when CreateClient.
- “ERR_INVALID_APP_ID”: Invalid app Id. [Will not reconnect]
- “ERR_INVALID_TOKEN”: Invalid token. [Will not reconnect]
- “ERR_TOKEN_EXPIRED”: The token has expired. [Will not reconnect]
- “ERR_ENTERPRISE_CONCURRENT_POINTS_EXCEED_LIMIT”: Enterprises concurrently out of the limit. [Will not re-connect]
- “ERR_REFUSED”: Other errors. [Will not re-connect]
// Example:
client.on("signal-connect-fail", function(evt) {
console.log("signal-connect-fail", evt);
});
need-reload-page
What it does: The callback notification interface needs to be reloaded (ie: interface refresh).
Note: After testing, it was found that some machines on Win8.1 failed to open the camera after the request of the video device failed. The SDK will remember this device state, but the interface needs to be reloaded (ie: interface refresh) to restore the use of the camera.
// Example:
client.on("need-reload-page", function(evt) {
console.log("need-reload-page", evt);
window.location.reload();
});
client-role-changed
What it does: This callback notifies the role of the local user changes.
Live scenes, this callback is triggered when the user role switch is switched, that is, the anchor is switched to the audience, or the audience switches to an anchor.
Callback parameter evt structure:
// Example:
client.on("client-role-changed", function(evt) {
console.log("client-role-changed", evt);
});
request-token
What it does: This callback notifies the App that a new Token needs to be generated, and then calls join Channel to rejoin the channel with the new Token.
Callback parameter evt structure:
{
token:"token encrypted string"
}
Note:
- When receiving this callback, the SDK has automatically left the channel.
- Token is generated by a combination of authkey, secretkey, channel, userid, and expiretime, so please ensure that the authkey, secretkey, channel, and userid used by the newly generated token remain unchanged.
// Example:
client.on("request-token", function(evt) {
console.log("request-token", evt);
});
token-privilege-will-expire
What it does: This callback informs the App Token service that the callback is about to expire.
Callback parameter evt structure:
{
token:"token encrypted string"
}
Note:
- If you specify a Token when calling join Channel, 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 App to update the Token. When receiving the callback, the user needs to regenerate a new Token on the server, and then call renew Token to pass the newly generated Token to the SDK.
- Token is generated by a combination of authkey, secretkey, channel, userid, and expiretime, so please ensure that the authkey, secretkey, channel, and userid used by the newly generated token remain unchanged.
// Example:
client.on("token-privilege-will-expire", function(evt) {
console.log("token-privilege-will-expire", evt);
});
server-record-state-change
What it does: This callback notifies the App server that the recording status has changed.
Callback parameter evt structure:
{
isRecording:true,
isPause:false,
recordState:1,
startTs:1600152559163,
pauseDuration:2798,
recordDuration:9081,
currTs:1600152962101
}
Note:
- Record State value: 0: stop recording 1: start recording (recording) 2: pause recording 【Note: Resume recording record State value becomes 1】.
- When record State is 0, start Ts, pause Duration, and record Duration are all -1.
// Example:
client.on("server-record-state-change", function(evt) {
console.log("server-record-state-change", evt);
});
stream-publish-failure
What it does: This callback notifies the App stream that the publishing failed. After this event is triggered, the stream will not be republished.
Callback parameter evt structure:
{
reason:"PUBLISH_STREAM_LIMIT",
stream:Stream
}
Note: Note:reason The following values are available
- “STREAM_ALREADY_PUBLISHED”: The stream has been published.
- “INVALID_LOCAL_STREAM”: The format of the incoming stream is illegal.
- “STREAM_NOT_INITED”: Local flow is not initialized.
- “SIGNAL_NOT_CONNECT”: Not currently not in the channel, it may be no channel or network fluctuation caused temporary disconnection.
- “PUBLISH_STREAM_LIMIT”: The maximum number of audio and video channels released exceeds the limit.
- “PUBLISH_NOT_PERMISSION”: No permission release.
- “PUB_SETREMOTEDESC_FAIL”: Browser setRemoteDescription failed, about setRemoteDescription See https://developer.mozilla.org/zh-CN/docs/Web/API/RTCPeerConnection/setRemoteDescription
// Example:
client.on("stream-publish-failure",function(evt){
var stream = evt.stream;
console.log("stream-publish-failure",stream.getId());
})
stream-subscribe-failure
What it does: This callback notifies the App stream subscription failure. After this event is triggered, the stream will not be re-subscribed.
Callback parameter evt structure:
{
reason:"SUBSCRIBE_NOT_PERMISSION",
stream:Stream
}
Note: Note:Reason has the following values
- “STREAM_ALREADY_SUBSCRIBED”: The stream is already subscribed.
- “STREAM_NOT_YET_PUBLISHED”: The specified stream has not been published.
- “INVALID_REMOTE_STREAM”: The format of the incoming stream is illegal.
- “SIGNAL_NOT_CONNECT”: Not currently not in the channel, it may be no channel or network fluctuation caused temporary disconnection.
- “SUBSCRIBE_NOT_PERMISSION”: No authority subscription.
- “SUB_SETREMOTEDESC_FAIL”: Browser setRemoteDescription failed, about setRemoteDescription See https://developer.mozilla.org/zh-CN/docs/Web/API/RTCPeerConnection/setRemoteDescription
// Example:
client.on("stream-subscribe-failure",function(evt){
var stream = evt.stream;
console.log("stream-subscribe-failure",stream.getId());
})
publish-permission
What it does: This callback informs whether the App has publishing permission.
Callback parameter evt structure:
{
hasPermission: true
}
Note:
- Before entering the channel, it is considered that there is publishing permission. If you do not have the publishing permission, you will receive a callback of Client.on(“publish-permission”) after entering the channel. At this time, has Permission is false.
- Channel disconnect reset will be reset to: has permission status
// Example:
client.on("publish-permission", function(evt) {
console.log("publish-permission", evt);
})
subscribe-permission
What it does: This callback informs whether the App has subscription permission.
Callback parameter evt structure:
{
hasPermission: true,
}
Note:
- You are considered to have subscription permission before entering the channel. If you do not have the subscription permission, you will receive a callback from Client.on(“subscribe-permission”) after entering the channel. In this case, hasPermission is false.
- Channel disconnection, please reset the subscription permissions to: has permission status
// Example:
client.on("subscribe-permission", function(evt) {
console.log("subscribe-permission", evt);
})
channel-media-relay-state
What it does: This callback notifies the app of the status of cross-room streaming.
Callback parameter evt structure:
{
destChannelName: 'dest01',
connState: 'connecting',
stateDesc: 'connecting to dest channel'
}
There are several situations in connState:
- connecting: Establishing a connection with the target channel
- connected: Successfully established a connection with the target channel
- invalidDestChanne: The channelName of the target channel is invalid
- connectFai: Failed to establish a connection with the target connection
- connectLost: The connection to the target is broken
- unknownError: Unknown error
- stop: Actively disconnect from the target(That is, the user calls the startChannelMediaRelay/updateChannelMediaRelay/stopChannelMediaRelay interface active disconnection)
- clientRoleNotHost: Users are not an anchor (That is: clientRole is not host)
Note:
- channel-media-relay-state Only the initiator of the flow (that is, the interface caller) can receive this event notification.
- When connState is “stop”, the connection is actively closed, and the server removes the connection from the list of connections forwarded by the stream and no longer notifies the link.
- When connState is “connected”, the source channel is connected to the destination channel successfully, and the server starts to forward the flow of the API caller to the target room user.
- When the conn State changes from “connected” to non-“connected”, the server will stop forwarding the flow of the interface caller.
- When connState changes from “connected” to non-“connected”, no reconnection occurs.
- When connState is “connected”, the following notification is given: The user of the target channel will trigger the client.on(“peer-join”) event, which carries the channel name from which the fromChannelName indicates the interface caller. If the interface caller publishes the stream, the user of the target channel will trigger the client.on(“stream-added”) event.
- When connState changes from “connected” to non-“connected”, the following notification is given: The user of the target channel triggers the client.on(“peer-leave”) event, and if the interface caller publishes the stream, the user of the target channel triggers the client.on(“stream-removed”) event.
// Example:
client.on("channel-media-relay-state", function(evt) {
console.log("channel-media-relay-state", evt);
})
channel-force-closed
What it does: This callback informs that the App channel has been forcibly closed.
Callback parameter evt structure:
{
reasoncode: 1,
}
sound and video
stream-volume-indicator
What it does: This callback periodically returns the volume reminder of the published/subscribed stream.
Disabled by default. It can be turned on through the enableAudioVolumeIndicator (interval?:number) method; when turned on, the volume prompt will be returned every interval millisecond, regardless of whether someone is speaking in the channel.
The volume range is an integer between 0 and 100.
Only return volume prompts with video type (that is, stream.getType() = “video”)
Callback parameter evt structure:
[{
stream:Stream
volume:10,
}]
// Example:
client.on("stream-volume-indicator", function(evt){
var volsobj = {};
evt.forEach(function(item){
volsobj[item.stream.getId()] = item.volume;
});
console.log("recv client event, stream-volume-indicator", volsobj);
});
stream-published
What it does: This callback notifies the App that the local audio and video stream has been released.
Callback parameter evt structure:
{
stream:Stream
}
// Example:
client.on("stream-published", function(evt) {
console.log("stream-published", evt.stream.getId());
})
stream-unpublished
What it does: This callback notification application The local audio and video stream has been released.
Callback parameter evt structure:
{
stream:Stream
}
// Example:
client.on("stream-unpublished", function(evt) {
console.log("stream-unpublished", evt.stream.getId());
})
first-audio-frame-decode
What it does: The remote audio first frame decoding callback has been completed.
The callback is triggered when the local subscription remote stream is successful and the first frame of audio decoding is completed.
Callback parameter evt structure:
{
stream:Stream
}
Note: Edge browser does not support
// Example:
client.on('first-audio-frame-decode', function (evt) {
console.log('first-audio-frame-decode');
console.log(evt.stream.getId());
});
first-video-frame-decode
What it does: The callback for decoding the first frame of the remote video has been completed.
This callback is triggered when the remote stream is successful and the first frame of video decoding is completed.
Callback parameter evt structure:
{
stream:Stream
}
Note: Edge browser does not support
// Example:
client.on('first-video-frame-decode', function (evt) {
console.log('first-video-frame-decode');
console.log(evt.stream.getId());
})
stream-added
What it does: This callback notifies App that the remote audio and video stream has been added.
Callback parameter evt structure:
{
stream:Stream
}
// Example:
client.on("stream-added", function(evt) {
var stream = evt.stream;
console.log("new stream added", stream.getId());
})
stream-removed
What it does: This callback informs App that the remote audio and video stream has been deleted.
Callback parameter evt structure:
{
stream:Stream
}
// Example:
client.on("stream-removed", function(evt) {
var stream = evt.stream;
console.log("remote stream was removed", stream.getId());
});
stream-reconnect-start
What it does: This callback informs SDK to start trying to republish / subscribe to the audio / video stream.
Callback parameter evt structure:
{
reason:"PUB_FAILED",
stream:Stream
}
Note: Reason has the following values
- “PUB_ACK_FAILED”: ACK fails to be published, usually because the connection is lost during the publishing process [Note: The SDK will automatically republish if this fails].
- “PUB_TIMEOUT”: Publish timeout [Note: SDK will automatically republish].
- “PUB_CONNECTION_FAILED”: Failed to establish media transmission channel after publishing [Note: SDK will automatically republish].
- “PUB_CONNECTION_INSTABILITY”: The stream has been successfully published, but the media transmission channel is unstable, and it needs to be republished forcibly [Note: SDK will automatically republish].
- “PUB_CONNECTION_ICE_DISCONNECTED”: The stream has been successfully published, but the media transmission channel is disconnected [Note: SDK will automatically republish].
- “PUB_APP_HIDDEN_CATON”: After the release is successful, the app is hidden (for example, pressing the Home button) and then the APP is redisplayed, which causes a freeze [Note: SDK will automatically republish].
- “PUB_UNDEFINED_FAIL”: Undefined publishing failed [Note: SDK will automatically republish].
- “PUB_SDK_FORCE_RECONN”: Because the browser version is too low, to switch the device/switch resolution, you need to force a re-release [Note: SDK will automatically re-release].
- “SUB_ACK_FAILED”: The ACK subscription fails, usually because the connection is disconnected during the subscription process [Note: SDK will automatically re-subscribe].
- “SUB_TIMEOUT”: Subscription timed out [Note: SDK will automatically re-subscribe].
- “SUB_CONNECTION_FAILED”: Failed to establish media transmission channel after subscribing [Note: SDK will automatically re-subscribe].
- “SUB_CONNECTION_INSTABILITY”: The stream has been subscribed successfully, but the media transmission channel is unstable, and it needs to be forced to re-subscribe [Note: SDK will automatically re-subscribe].
- “SUB_CONNECTION_ICE_DISCONNECTED”: The stream has been subscribed successfully, but the media transmission channel is disconnected [Note: SDK will automatically re-subscribe].
- “SUB_APP_HIDDEN_CATON”: After the subscription is successful, the app is hidden (for example, pressing the Home button) and then the app is redisplayed, causing a freeze [Note: SDK will automatically re-subscribe].
- “SUB_UNDEFINED_FAIL”: Undefined subscription failed [Note: SDK will automatically re-subscribe].
// Example:
client.on("stream-reconnect-start", function(evt) {
console.log(evt.stream.getId(), evt.reason);
})
stream-reconnect-end
What it does: This callback notifies the end of republishing/subscribing audio and video streams.
Callback parameters evt structure
{
reason:"",
success:true,
stream:Stream
}
// Example:
client.on('stream-reconnect-end', function(evt) {
console.log(evt.stream.getId(), evt.success, evt.reason);
})
stream-subscribed
What it does: This callback notifies the app that the remote audio and video stream has been subscribed.
Callback parameter evt structure:
{
stream:Stream
}
// Example:
client.on("stream-subscribed", function(evt) {
var stream = evt.stream;
console.log("stream-subscribed", stream.getId());
})
stream-unsubscribed
What it does: This callback notifies the app that the remote audio and video stream has been unsubscribed.
Callback parameter evt structure:
{
stream:Stream
}
// Example:
client.on("stream-unsubscribed", function(evt) {
var stream = evt.stream;
console.log("stream-unsubscribed", stream.getId());
})
stream-network-quality
What it does: This callback reports the network quality of the stream.
This callback is triggered every 2 seconds and reports the current uplink and downlink network quality of the local user to the App.
Callback parameter evt structure:
[{
stream:Stream //stream:Stream Stream Object
quality:NetworkQualityStats //quality:object NetworkQualityStats See CloudHubRTC Data object document
}]
Note: Edge browser does not support
// Example:
client.on("stream-network-quality", function (evt) {
var netobjs = {};
evt.forEach(function(item){
netobjs[item.stream.getId()] = item.quality;
});
console.log("recv client event, stream-network-quality", netobjs);
})
mute-audio
What it does: This callback notifies the other user of the App to turn off their voice.
Callback parameter evt structure:
{
stream:Stream
}
// Example:
client.on("mute-audio", function(evt) {
console.log("mute audio:" + evt.stream.getId());
});
unmute-audio
What it does: This callback notifies the other user of the App to turn on their voice.
Callback parameter evt structure:
{
stream:Stream
}
// Example:
client.on("unmute-audio", function (evt) {
console.log("unmute audio:" + evt.stream.getId());
});
mute-video
What it does: This callback notifies the other user of the App to turn off their video.
Callback parameter evt structure:
{
stream:Stream
}
// Example:
client.on("mute-video", function (evt) {
console.log("mute video" + evt.stream.getId());
})
unmute-video
What it does: This callback notifies the other user of the App to turn on their video.
Callback parameter evt structure:
{
stream:Stream
}
// Example:
client.on("unmute-video", function (evt) {
console.log("unmute video:" + evt.stream.getId());
})
Signaling
recv-pub-msg
What it does: This callback notifies the App that the “send signaling message” has been received.
Callback parameter evt structure:
{
isNowMsg :true,
fromID: "7f890bd6-d79d-9b99-3861-5dc08377ab6a",
data: {info: "pubMsg"},
id: "TestPubmsgId",
name: 'TestPubmsg',
seq: 1,
toID: "__all",
ts: 1587974788
}
Note: isNowMsg If it is true, it means that the signaling message is sent after the user himself joins the channel. If it is false, it means that the signaling message was sent before the user himself joined the channel.
// Example:
client.on("recv-pub-msg", function(evt){
console.log(evt);
});
recv-del-msg
What it does: This callback notifies the App that the “delete signaling message” has been received.
Callback parameter evt structure:
{
fromID: "7f890bd6-d79d-9b99-3861-5dc08377ab6a",
id: "TestPubmsgId",
name: "TestPubmsg",
seq: 1,
toID: "__all",
ts: 1587974788
}
// Example:
client.on("recv-del-msg", function(evt){
console.log(evt);
});
signal-connected
What it does: The callback notifies that a connection has been successfully established with the server.
Callback parameter evt structure:
{
currServerTs: 1587974203,
}
// Example:
client.on("signal-connected", function(evt) {
console.log("signal-connected", evt);
});
signal-reconnect
What it does: The callback notification is reconnecting to the server.
Note: When you receive this event, you need to clear the cached data in the UI layer, such as flow lists, user lists, UI interfaces, and so on.
// Example:
client.on("signal-reconnect", function() {
console.log("signal-reconnect");
})
signal-connection-state-change
What it does: This callback notifies App SDK that the state of the connection to the server has changed.
There are three connection states between SDK and the server:
- DISCONNECTED:Disconnect. This status indicates that the SDK is in any of the following stages:
- The Initialization Phase before Call Client.joinChannel to joining the channel
- Leave the channel phase after call Client.leaveChannel
- CONNECTING:Connecting. This is the state when Client.joinChannel is called or when the connection is broken and automatically reconnected.
- CONNECTED:Connected. This status indicates that the user has joined the channel and can publish or subscribe to media streams within the channel. If the connection between SDK and the server is interrupted due to network disconnection or switching, SDK will automatically reconnect, and App will receive the callback notifying that the network status has changed from CONNECTED to CONNECTING.
Callback parameter evt structure:
{
curState:"CONNECTING",
prevState:"CONNECTED"
}
Note:
When the status changes to DISCONNECTED, you need to clear the data cached in the UI layer, such as flow list, user list, UI interface, channel closed connection, and so on. [note: this status is usually triggered when the user calls leaveChannel or is kicked out of the channel. It will be really disconnected from the server and will not be reconnected]
When you receive a signal-reconnect event (that is, the status is CONNECTING),), you need to clear the cached data in the UI layer, such as flow lists, user lists, UI interfaces, and so on. [note: this state generally means that the current network is disconnected from the server and will be reconnected, and the server will be reconnected when the network is restored]
// Example:
client.on("signal-connection-state-change", function(evt) {
console.log(evt.prevState, evt.curState);
})
Chat
recv-chat-msg
What it does: The callback informs App that a chat message was received.
Callback parameter evt structure:
{
fromID: "7f890bd6-d79d-9b99-3861-5dc08377ab6a",
message:"abcd",
extraData: {
nickname: "Superman",
role: 2,
sendTs: 1587974207200,
key1: 'value1',
key2: 'value2',
...sendExtraData
}
}
// Example:
client.on("recv-chat-msg", function(evt){
console.log(evt);
});
User
peer-join
What it does: This callback reminds that a remote user/host has joined the channel.
In the communication scenario, the callback prompts that a remote user has joined the channel, and returns the ID and custom user attributes of the new user; if there are other users in the channel before joining, the new user will also receive these Callback for an existing user to join the channel.
In the live broadcast scenario, the callback prompts that an anchor has joined the channel, and returns the anchor’s ID and custom user attributes. If there is an anchor in the channel before joining, the new user will also receive a callback for the existing anchor to join the channel.
The callback will be triggered under the following circumstances:
- The remote user in the communication scene/the remote host in the live broadcast scene calls the Client.join Channel method to join the channel.
- The remote audience in the live broadcast scene joins the channel and calls Client.set Client Role to change the user’s role as the host.
- The remote user in the communication scene/the remote host in the live broadcast scene is disconnected from the network and rejoins the channel.
- When the remote viewer in the live broadcast scene calls the Client.publish method, the SDK will automatically switch the user role as the host.
Callback parameter evt structure:
{
isNowUser:true,
id: 'uid',
properties: {}
}
Note: isNowUser If it is true, it means that the user joined the channel after the user joined the channel. If it is false, it means that the user joined the channel before the user joined the channel.
// Example:
client.on("peer-join", function(evt) {
console.log("peer-join", evt);
});
peer-leave
What it does: The callback notifies the application that a remote user is offline.
This callback will be triggered in the following cases:
- The remote user in the communication scene/the remote host in the live broadcast scene calls the Client.leaveChannel method to leave the channel.
- The remote host in the live broadcast scene joins the channel and calls Client.setClientRole to change the user role to audience.
- The remote user in the communication scene/the remote host in the live broadcast scene is disconnected from the network.
- The remote user in the communication scene/the remote host in the live broadcast scene is kicked out of the channel.
- The remote user in the communication scene/the remote host in the live broadcast scene has entered the channel and left the channel because of the same user id.
- Because the server actively closes the channel, all users are kicked out (remote users in the communication scene/remote host in the live broadcast scene will receive a callback).
- The remote host of the live broadcast scene calls the Clinet.unpublish method and there is no local stream being published, the SDK will automatically switch the user role to the audience.
Callback parameter evt structure:
{
id: 'uid', //id:string User id
reason: 'Quit', //reason: string Reasons for users to leave
reasoncode: 1, //reasoncode:number Leave reason code
}
Reasons for users going offline.
- “Quit”: The user called the Client.leaveChannel Leave the channel voluntarily.(reasoncode is 1)
- “ServerTimeOut”: Due to a long time can not receive each other packet, time out of line. Note: Since the SDK uses an unreliable channel, it is also possible that the other party left the party did not receive the other party’s departure message and mistakenly judged as a time-out dropped.(reasoncode is 2)
- “KickedOut”: The user is kicked out.(reasoncode is 3)
- “CommonUidJoin”: Leaving the channel because the same user id entered the channel.(reasoncode is 4)
- “ServerCloseChannel”: Because the server actively shuts down the channel, kick out all users.(reasoncode is 5)
- “BecomeAudience”: User roles are switched from an anchor to the audience.(reasoncode is 6)
- “Unknown”: Leave the channel for an unknown reason.(reasoncode is 0)
- “R2RChannelActiveClose”: Cross-room channel active shutdown (reasoncode is 8)
- “R2RChannelConnectLost”: Cross-room channel connection disconnection (reasoncode is 9)
- “Undefined”: Undefined reason.(The specific reason code is defined, and the value of reasoncode is based on the value received.)
Note: In live broadcast scenarios, only characters are an anchor user triggering the callback.
// Example:
client.on("peer-leave", function(evt) {
console.log("peer-leave", evt);
});
user-properties-update
What it does: This callback notifies the App user of the update of the custom properties.
Callback parameter evt structure:
{
fromID: "fb4be6d4-4cfa-9d54-94b6-f58433baf88d",
id: "fb4be6d4-4cfa-9d54-94b6-f58433baf88d",
properties: {
publishstate: 0
}
toID: "__all",
ts: 1589875212
}
Note:
- The setProperty interface is called in the live broadcast scene. If the changed person is an audience, the custom user property change will not be notified, that is, Client.on(“user-properties-update”) will not trigger the callback.
- It is not recommended that viewers call the setProperty interface in the live broadcast scene.
// Example:
client.on("user-properties-update", function(evt) {
console.log("user-properties-update", evt);
});
peer-evicted
What it does: This callback notifies the App user that he has been kicked out of the channel.
Callback parameter evt structure:
{
fromID: 'uid',
reason: 'reason'
}
Note:
- A fromID of “__YSServer” indicates that the user is kicked by the server. Generally, the server kicks people because the same uid joins the channel.
- If fromID is “__YSServer”, reason is the empty string “”.
// Example:
client.on("peer-evicted", function(evt) {
console.log("peer-evicted", evt);
});
Equipment
camera-device-changed
What it does: This callback notifies the App that a camera has been added or removed.
Callback parameter evt structure:
{
state: 'add',
devices:[{
kind: 'videoinput',
label: 'label',
deviceId: 'deviceid'
}]
}
// Example:
client.on("camera-device-changed", function(evt) {
console.log("camera-device-changed", evt.state, evt.devices);
});
microphone-device-changed
What it does: This callback notifies the App that a microphone has been added or removed.
Callback parameter evt structure:
{
state: 'add',
devices: [{kind:"audioinput",label:"label",deviceId:"deviceid"}]
}
// Example:
client.on("microphone-device-changed", function(evt) {
console.log("microphone-device-changed", evt.state, evt.devices);
});
speaker-device-changed
What it does: This callback notifies the App that a speaker has been added or removed.
Callback parameter evt structure:
{
state: 'add',
devices: [{
kind:'audiooutput',
label:'label',
deviceId:'deviceid'
}]
}
// Example:
client.on("speaker-device-changed", function(evt) {
console.log("speaker-device-changed", evt.state, evt.devices);
});