TKRoomSDK event description
TKRoomSDK event description
Mount the listener
- The room event listener needs to be mounted on the room instance. You can customize an event dispatcher to forward events
| const room = TK.Room()
const dispatcher = TK.EventDispatcher()
function registerRoomEvent() {
room.addEventListener(event, (recvEventData) => {
dispatcher.dispatchEvent(recvEventData, false)
})
}
registerRoomEvent()
|
Joined the room successfully(TK.EVENT_TYPE.roomConnected)
- This event is dispatched when the current user successfully enters the room. You can use this event to determine the user's connection status
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name: TK.EVENT_TYPE.roomConnected |
message |
Array |
The signaling messages currently existing in the room (messages published and saved via pubMsg) |
isReconnect |
Boolean |
Whether it is a reconnection to the room |
| const onRoomConnectSuccess = data => {
console.log("room event type: ", data.type);
console.log("connect success data: ", data.message);
alert("Succeed in joining the room")
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomConnected, onRoomConnectSuccess)
|
Failed to join the room(TK.EVENT_TYPE.roomConnectFail)
Parameter name |
Type |
Description |
type |
String |
Event name: TK.EVENT_TYPE.roomConnectFail |
message |
Object |
source: Indicates which step of the join room operation has been reached.error: The reason for the error. Possible status code values can be found in the global error codes |
| const onRoomConnectFailed = data => {
console.log("room event type: ", data.type);
console.log("connect fail source: ", data.message.source);
console.log("connect fail error: ", data.message.error);
alert("Fail to join the room")
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomConnectFail , onRoomConnectFailed)
|
Room connection interrupted(TK.EVENT_TYPE.roomDisconnected)
- This event is dispatched when the connection to the current room is interrupted. Possible reasons include network disconnection, network jitter, or a weak network environment. You can listen to this event to provide corresponding prompts
- When the room connection is interrupted, the SDK will automatically attempt to reconnect internally
Event data:
Parameter name |
Type |
Description |
type |
String |
Event name: TK.EVENT_TYPE.roomDisconnected |
| const onRoomDisconnect = data => {
console.log("room event type: ", data.type);
alert("Network jitter, reconnecting...")
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomDisconnected , onRoomDisconnect)
|
Leave the room(TK.EVENT_TYPE.roomLeaveRoom)
- This event is dispatched when the current user successfully leaves the room. At this point, the user's connection has been disconnected. You can listen to this event to perform some cleanup tasks
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name: TK.EVENT_TYPE.roomLeaveRoom |
| const onRoomLeaveRoom = data => {
console.log("room event type: ", data.type);
alert("The current user has exited the classroom")
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomLeaveRoom , onRoomLeaveRoom)
|
User joined the room(TK.EVENT_TYPE.roomParticipantJoin)
- This event is dispatched when other users successfully join the room (rules may differ in large-scale rooms). You can listen to this event to notify users of their successful entry
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name: TK.EVENT_TYPE.roomParticipantJoin |
user |
Object |
User information of the person joining the room |
| const onRoomUserJoin = data => {
console.log("room event type: ", data.type);
console.log("user join info: ", data.user)
alert(data.user.nickname + "Joined the room")
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomParticipantJoin , onRoomUserJoin)
|
User left the room(TK.EVENT_TYPE.roomParticipantLeave)
- This event is dispatched when other users successfully leave the room (rules may differ in large-scale rooms). You can listen to this event to notify users of their departure
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name:TK.EVENT_TYPE.roomParticipantLeave |
user |
Object |
User information of the person leaving the room |
| const onRoomUserLeave = data => {
console.log("room event type: ", data.type);
console.log("user leave info: ", data.user)
alert(data.user.nickname + "Left the room")
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomParticipantLeave , onRoomUserLeave)
|
The user was kicked out of the room(TK.EVENT_TYPE.roomParticipantEvicted)
- This event is dispatched when a user is kicked out of the room. Only the user who is kicked out will receive this event. You can listen to this event to provide relevant notifications
- In some cases, the server may proactively kick someone out of the room. The following are explanations for the message.reasoncode when the server kicks someone out
- 400, A user with the same ID has entered the room repeatedly. The user who entered the room first will be kicked out
- 401, The room has reached the set end time, or the teacher left the room and did not return within the specified time
- 402, The room has been disabled (via the backend or WebAPI)
- Event data:
Parameter name |
Type |
Description |
type |
String |
Eventname: TK.EVENT_TYPE.roomParticipantEvicted |
user |
Object |
Information of the user who was kicked out |
message |
Object |
Reason and related information for being kicked out |
| const onRoomUseEvicted = data => {
console.log("room event type: ", data.type);
console.log("user evict reason: ", data.message)
console.log("reason code: ", data.message.reason)
alert( "You have been kicked out of the room")
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomParticipantEvicted , onRoomUseEvicted)
|
Received a chat message(TK.EVENT_TYPE.roomTextMessage)
- The event is triggered when a room chat message is received. Users can listen to this event to display the chat message
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name: TK.EVENT_TYPE.roomTextMessage |
user |
Object |
Sender information of the chat message |
message |
Object |
Content of the chat message |
userid |
String |
Sender ID of the chat message |
nickname |
String |
Nickname of the chat message sender |
role |
Number |
Role of the chat message sender, specific values refer to the room roles |
| const onRoomTextMessage = data => {
console.log("room event type: ", data.type);
console.log("room message info: ", data.message)
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomTextMessage , onRoomTextMessage)
|
Custom message published(TK.EVENT_TYPE.roomPubmsg)
- The event is triggered when a custom room message is received. Users can listen to this event to respond to the start of various custom room operations
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name: TK.EVENT_TYPE.roomPubmsg |
message |
Object |
Content of the custom published message |
| const onRoomPubmsg = data => {
console.log("room event type: ", data.type);
console.log("room message info: ", data.message)
if (data.message.name === "testStart") {
consoel.log("The exam has begun")}
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomPubmsg , onRoomPubmsg)
|
Custom message deleted(TK.EVENT_TYPE.roomDelmsg)
- The event is triggered when a custom room deletion message is received. Users can listen to this event to respond to the end of various custom room operations
- A custom message must first be published in the room before a corresponding custom message deletion can be received
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name: TK.EVENT_TYPE.roomDelmsg |
message |
Object |
Content of the custom deletion message |
| const onRoomDelmsg = data => {
console.log("room event type: ", data.type);
console.log("room message info: ", data.message)
if (data.message.name === "testStart") {
consoel.log("The exam is over")}
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomDelmsg , onRoomDelmsg)
|
User attributes changed(TK.EVENT_TYPE.roomUserPropertyChanged)
- The event is triggered when a user's attributes change. Users who match the message recipient role (see message sender role) will receive this message. This message can be listened to for room-related business concerning user attribute changes
- In the large room mode, if the toId of changeUserProperty is TK.MSG_TO_ALLUSER or TK.MSG_TO_ALLEXCEPTSENDER, then the user attribute changes of users who have not taken the stage are only forwarded to the caller (i.e., the one who calls changeUserProperty) and the target user (i.e., the user whose attributes are changed). However, if the user attribute changes belong to a user who has taken the stage (i.e., a user publishing audio/video), the changes are forwarded to the specified users according to the toId.
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name: TK.EVENT_TYPE.roomUserPropertyChanged |
user |
Object |
Information of the user whose attributes are modified |
message |
Object |
The modified user attributes |
userId |
String |
The ID of the user whose attributes are modified |
fromID |
String |
The ID of the user who initiated the attribute modification |
| const onRoomUserPropertyChanged = data => {
console.log("room event type: ", data.type);
console.log("change property info: ", data.message)
if (data.userId === "myId" && data.message.hasOwnProperty("level") ) {
cosnole.log("My user attributes have been modified. The modified attribute is "level", and my new level is: " + data.message.level)}
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomUserPropertyChanged , onRoomUserPropertyChanged)
|
User's video publishing status changed(TK.EVENT_TYPE.roomUserVideoStateChanged)
- The event is triggered when the user's video publishing status changes. You can listen to this event to play or close the user's video
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name:TK.EVENT_TYPE.roomUserVideoStateChanged |
message |
Object |
Video publishing status information, with detailed information as follows |
Parameter name |
Type |
Description |
userId |
String |
The ID of the user whose video publishing status has changed |
published |
Boolean |
Publish or stop publishing |
deviceId |
String |
Note: The deviceId is only available for videos published in multi-video mode |
| const onRoomUserVideoStateChanged = data => {
console.log("room event type: ", data.type);
console.log("data info: ", data.message)
if (data.message.published) {
room.playVideo(data.message.userId, "video-dom")
} else {
room.unplayVideo (data.message.userId)}
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomUserVideoStateChanged , onRoomUserVideoStateChanged)
|
User's audio publishing status changed(TK.EVENT_TYPE.roomUserAudioStateChanged)
- The event is triggered when the user's audio status changes. You can listen to this event to play or mute the user's audio
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name: TK.EVENT_TYPE.roomUserAudioStateChanged |
message |
Object |
Video publishing status information, with detailed information as follows |
Parameter name |
Type |
Description |
userId |
String |
The user ID whose audio publishing status has changed |
published |
Boolean |
Publish or stop publishing |
| const onRoomUserAudioStateChanged = data => {
console.log("room event type: ", data.type);
console.log("data info: ", data.message)
if (data.message.published) {
room.playAudio(data.message.userId)
} else {
room.unplayAudio(data.message.userId)}
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomUserAudioStateChanged , onRoomUserAudioStateChanged)
|
- The event is triggered when the user's media file sharing status changes. You can listen to this event to play or close the shared media file
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name:TK.EVENT_TYPE.roomUserMediaStateChanged |
message |
Object |
Shared media file publishing status information, with detailed information as follows |
Parameter name |
Type |
Description |
userId |
String |
The user ID who shared the media file |
type |
String |
Media file type: media or file |
published |
Boolean |
Publish or stop publishing |
attributes |
Object |
Media file attributes. Including media file width and height, duration, file name, whether it is paused, whether it contains audio and video, etc |
| const onRoomUserMediaStateChanged = data => {
console.log("room event type: ", data.type);
console.log("data info: ", data.message)
if (data.message.published && data.message.type === "mdeia") {
room.playRemoteMedia(data.message.userId, "media-dom")
}
if (!data.message.published && data.message.type === "mdeia") {
room.unplayRemoteMedia(data.message.userId)}
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomUserMediaStateChanged , onRoomUserMediaStateChanged)
|
User's screen sharing status changed(TK.EVENT_TYPE.roomUserScreenStateChanged)
- The event is triggered when the user's screen sharing status changes. You can listen to this event to play or close the shared screen
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name:TK.EVENT_TYPE.roomUserScreenStateChanged |
message |
Object |
Screen sharing publishing status information, with detailed information as follows |
Parameter name |
Type |
Description |
userId |
String |
The user ID who shared the screen |
type |
String |
Screen sharing type: screen |
published |
Boolean |
Publish or stop publishing |
attributes |
Object |
Screen sharing stream attributes. Including the video stream width and height, whether it contains audio, whether it contains video, etc |
| const onRoomUserScreenStateChanged = data => {
console.log("room event type: ", data.type);
console.log("data info: ", data.message)
if (data.message.published && data.message.type === "screen") {
room.playRemoteScreen(data.message.userId, "screen-dom")
}
if (!data.message.published && data.message.type === "screen") {
room.unplayRemoteScreen(data.message.userId)}
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomUserScreenStateChanged , onRoomUserScreenStateChanged)
|
- The event is triggered when the attributes of a shared media file change. You can listen to this event to provide prompts for pausing or resuming playback of the shared media file (video will automatically pause)
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name:TK.EVENT_TYPE.roomUserMediaAttributesUpdate |
message |
Object |
Shared media file publishing attribute update information, with detailed information as follows |
Parameter name |
Type |
Description |
userId |
String |
The user ID who shared the media file |
type |
String |
Media file type: media or file |
attributes |
Object |
Media file attributes. Including media file width and height, duration, file name, whether it is paused, whether it contains audio and video, etc |
updateAttributes |
Object |
Updated media file attributes |
| const onRoomUserMediaAttributesUpdate = data => {
console.log("room event type: ", data.type);
console.log("data info: ", data.message)
if (data.message.type === "media" && data.message.updateAttributes.pause) {
console.log("media paused")}
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomUserMediaAttributesUpdate , onRoomUserMediaAttributesUpdate)
|
- After the room object is initialized (init), this event will be triggered if there are available devices
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name: TK.EVENT_TYPE.deviceSuccess |
message |
Object |
Types of available devices { kind: "videoinput" |
| const onDeviceSuccess = data => {
console.log("room event type: ", data.type);
console.log("data info: ", data.message)
console.log(data.message.kind + "is avaliable")
}
dispatcher.addEventListener(TK.EVENT_TYPE.deviceSuccess , onDeviceSuccess)
|
- After the room object is initialized (init), this event will be triggered if audio or video cannot be used normally due to various reasons
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name: TK.EVENT_TYPE.deviceFailure |
message |
Object |
Information of the unavailable devices { kind, deviceId } |
code |
Number |
Device failure error code, for specific values, refer to the SDK error codes |
| const onDeviceFailure = data => {
console.log("room event type: ", data.type);
console.log("data info: ", data.message)
console.log(data.message.kind + "is not avaliable, reason is: " + data.code)
}
dispatcher.addEventListener(TK.EVENT_TYPE.deviceFailure , onDeviceFailure)
|
-After the room object is initialized (init), this event will be triggered if there are any additions or removals of audio or video devices
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name: TK.EVENT_TYPE.deviceChange |
message |
Object |
Changed device information{ type, devices } |
| const onDeviceChange = data => {
console.log("room event type: ", data.type);
console.log("data info: ", data.message)
console.log("device change type: ", data.message.type) // data.message.type: TK.DEVICE_STATE.DEVICE_ADD(equipment addition) | TK.DEVICE_STATE.DEVICE_REMOVE(equipment removal)
console.log("device change devices: ", data.message.devices)
}
dispatcher.addEventListener(TK.EVENT_TYPE.deviceChange , onDeviceChange)
|
Primary camera changed(TK.EVENT_TYPE.roomUserMainCameraChanged)
- The event is triggered when the main camera changes in multi-camera mode
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name:TK.EVENT_TYPE.roomUserMainCameraChanged |
message |
Object |
Information about the change of the main camera |
Parameter name |
Type |
Description |
userId |
String |
User ID |
deviceId |
String |
The device ID of the new main camera |
| const onRoomUserMainCameraChanged = data => {
console.log("room event type: ", data.type);
console.log("data info: ", data.message)
console.log( data.message.userId + "The main camera device has changed, and the new device id is" + data.message.deviceId)
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomUserMainCameraChanged , onRoomUserMainCameraChanged)
|
First video frame(TK.EVENT_TYPE.roomFirstVideoFrame)
- The event is triggered when the video window is created and the video is ready to play
- If the joinRoom is not successful (i.e., the TK.EVENT_TYPE.roomConnected event is not received), then the userId will be ""
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name:TK.EVENT_TYPE.roomFirstVideoFrame |
message |
Object |
First frame of video related information |
Parameter name |
Type |
Description |
userId |
String |
User ID |
mediaType |
String |
Media type, for specific values, refer to the media type documentation |
width |
Number |
Video width |
height |
Number |
Video height |
deviceId |
String |
Video device ID. Note: This attribute is only available in multi-camera mode |
| const onRoomFirstVideoFrame = data => {
console.log("room event type: ", data.type);
console.log("data info: ", data.message)
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomFirstVideoFrame , onRoomFirstVideoFrame)
|
First audio frame(TK.EVENT_TYPE.roomFirstAudioFrame)
- The event is triggered when the audio player is created and the audio is ready to play
- If the joinRoom is not successful (i.e., the TK.EVENT_TYPE.roomConnected event is not received), then the userId will be ""
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name: TK.EVENT_TYPE.roomFirstAudioFrame |
message |
Object |
Information related to the first frame of audio |
Parameter name |
Type |
Description |
userId |
String |
User ID |
mediaType |
String |
Media type, for specific values, refer to the media type documentation |
File list(TK.EVENT_TYPE.roomFiles)
- The event is triggered when the file information in the room is fully retrieved. You can listen to this event to obtain the currently available files in the room
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name: TK.EVENT_TYPE.roomFiles |
message |
Array |
Room file information array. The structure of the file object is described as follows |
Parameter name |
Type |
Description |
fileid |
Number |
File ID |
companyid |
String |
Enterprise ID |
filename |
String |
File name |
uploaduserid |
String |
Uploader ID |
downloadpath |
String |
File download path |
swfpath |
String |
File view path |
filetype |
String |
File type |
pagenum |
Number |
Total number of pages. This field is only valid for ordinary static files and is not applicable to dynamic PPT and H5 files |
filecategory |
Number |
File category,0:room, 1:system |
fileprop |
Number |
File classification:0: Ordinary document, |
1-2: Dynamic PPT (1 for old version, 2 for new version),3: h5 document |
|
|
type |
Number |
Whether it is the default document: |
0: Non-default document, |
|
|
1: Default document |
|
|
| const onRoomFiles = data => {
console.log("room event type: ", data.type);
console.log("room file info: ", data.message)
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomFiles , onRoomFiles)
|
Add file(TK.EVENT_TYPE.roomAddFile)
- The event is triggered when a new file is successfully added to the room
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name: TK.EVENT_TYPE.roomAddFile |
message |
Object |
Description of the added file |
Parameter name |
Type |
Description |
fileid |
Number |
The ID of the added file |
fromID |
String |
The user ID of the uploader |
| const onRoomAddFile = data => {
console.log("room event type: ", data.type);
console.log("room new file info: ", data.message)
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomAddFile , onRoomAddFile)
|
Delete file(TK.EVENT_TYPE.roomDeleteFile)
- The event is triggered when a file is deleted in the room
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name: TK.EVENT_TYPE.roomDeleteFile |
message |
Object |
Description of the deleted file |
Parameter name |
Type |
Description |
fileid |
Number |
The ID of the deleted file |
fromID |
String |
The user ID of the deleter |
fileinfo |
Object |
Information of the deleted file |
| const onRoomDeleteFile = data => {
console.log("room event type: ", data.type);
console.log("room delete file info: ", data.message)
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomDeleteFile , onRoomDeleteFile)
|
Update file(TK.EVENT_TYPE.roomUpdateFile)
- The event is triggered when the file information in the room is updated
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name: TK.EVENT_TYPE.roomUpdateFile |
message |
Object |
Description of the updated file |
Parameter name |
Type |
Description |
fileid |
Number |
The ID of the updated file |
fromID |
String |
The user ID of the updater |
fileinfo |
Object |
Information of the updated file |
| const onRoomUpdateFile = data => {
console.log("room event type: ", data.type);
console.log("room update file info: ", data.message)
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomUpdateFile , onRoomUpdateFile)
|
Room mode changed(TK.EVENT_TYPE.roomModeChanged)
- The event is triggered when the room mode changes, such as switching from a normal room to a large room mode due to an excessive number of people in the classroom
- If it is the large room (i.e., large-scale room) mode, which means the roomMode is TK.ROOM_MODE.BIG_ROOM, certain interfaces or events will undergo changes. For details, refer to the Large Room (Large-Scale Room) Mode Description
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name:TK.EVENT_TYPE.roomModeChanged |
message |
Object |
New room mode { roomMode: roomMode }, for specific values, refer to the room mode documentation |
| const onRoomModeChanged = data => {
console.log("room event type: ", data.type);
console.log("room mode changed info: ", data.message)
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomModeChanged , onRoomModeChanged)
|
Server address updated(TK.EVENT_TYPE.roomServerAddressUpdate)
- The event is triggered when the server address is updated
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name: TK.EVENT_TYPE.roomServerAddressUpdate |
message |
Object |
New server address information |
Parameter name |
Type |
Description |
web_protocol |
String |
Protocol for web requests |
web_host |
String |
Domain name for web requests |
web_port |
Number |
Port for web requests |
doc_protocol |
String |
Protocol for document loading |
doc_host |
String |
Domain name for document loading |
doc_port |
Number |
Port for document loading |
backup_doc_protocol |
String |
Protocol for backup document loading |
backup_doc_host_list |
Array |
List of domain names for backup document loading |
backup_doc_port |
Number |
Port for backup document loading |
| const onRoomServerAddressUpdate = data => {
console.log("room event type: ", data.type);
console.log("room server address update info: ", data.message)
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomServerAddressUpdate , onRoomServerAddressUpdate)
|
User's network status changed(TK.EVENT_TYPE.roomUserNetworkStateChanged)
- The event is triggered to dispatch user network connection status messages
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name: TK.EVENT_TYPE.roomUserNetworkStateChanged |
message |
Object |
Network status information |
Parameter name |
Type |
Description |
userId |
String |
User ID |
deviceId |
String |
Video device ID. Note: The deviceId is only available for videos published in multi-video mode |
networkStatus |
Object |
Network status data, with detailed data format as follows |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 | {
// Video data statistics
video:{
bitsPerSecond:Bandwidth bps,
packetsLost:Packet loss count ,
totalPackets:Total packet count ,
packetsLostRate:Video packet loss rate ,
currentDelay:Delay ,
frameRate:Frame rate ,
frameWidth:Video width ,
frameHeight: Video height ,
timestamp:Timestamp ,
netquality:Network quality (for possible values, refer to [Network Status Quality]),
},
// Audio data statistics
audio:{
bitsPerSecond:Bandwidth bps ,
packetsLost:Packet loss count,
totalPackets:Total packet count ,
packetsLostRate:Audio packet loss rate ,
currentDelay:Delay ,
timestamp:Timestamp ,
netquality:Network quality (for possible values, refer to [Network Status Quality]),
}}
|
- Code example
| const onRoomUserNetworkStateChanged = data => {
console.log("room event type: ", data.type);
console.log("room user network state change info: ", data.message)
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomUserNetworkStateChanged , onRoomUserNetworkStateChanged)
|
User's network status statistics(TK.EVENT_TYPE.roomRtcStatsReportEvent)
- The event is triggered to dispatch the current user's network status statistics message
- The event begins to be dispatched once the user enters the classroom, with a frequency of 1 time per second
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name: TK.EVENT_TYPE.roomRtcStatsReportEvent |
message |
Object |
Network status information |
Parameter name |
Type |
Description |
stats |
Object |
Event data object, detailed as follows |
Parameter name |
Type |
Description |
audioDelay |
Number |
Audio publishing delay (ms) |
videoDelay |
Number |
Video publishing delay(ms) |
inAudioDelay |
Number |
Audio subscription delay(ms) |
inVideoDelay |
Number |
Video subscription delay(ms) |
inAudioKBitRate |
Number |
Audio subscription bitrate |
inVideoKBitRate |
Number |
Video subscription bitrate |
inBytes |
Number |
Number of bytes subscribed |
outBytes |
Number |
Number of bytes published |
inPackets |
Number |
Number of subscription packets |
outPackets |
Number |
Number of published packets |
downlinkDelay |
Number |
Total subscription delay(ms) |
uplinkDelay |
Number |
Total publishing delay(ms) |
downlinkDelayLevel |
Number |
Downlink network quality, refer to Network Status Quality |
uplinkDelayLevel |
Number |
Uplink network quality, refer to Network Status Quality |
duration |
Number |
Total duration(ms) |
| const onRoomRtcStatsReportEvent = data => {
const stats = data.message.stats}dispatcher.addEventListener(TK.EVENT_TYPE.roomRtcStatsReportEvent , onRoomRtcStatsReportEvent)
|
Server recording status updated(TK.EVENT_TYPE. roomServerRecordStateChange)
- The event is triggered when the server recording status is updated
- Event data
Parameter name |
Type |
Description |
type |
String |
Event name: TK.EVENT_TYPE.roomServerRecordStateChange |
message |
Object |
Current server recording status information |
Parameter name |
Type |
Description |
state |
String |
Recording status:start, pause, stop, resume |
fromID |
String |
User ID of the recorder status updater |
comRecId |
String |
Regular recording ID. Note: This attribute is only available when the status is start |
mp4RecId |
String |
MP4 recording ID. Note: This attribute is only available when the status is start |
| const onRoomServerRecordStateChange = data => {
console.log("room event type: ", data.type);
console.log("room server record info: ", data.message)
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomServerRecordStateChange , onRoomServerRecordStateChange)
|
Error message notification(TK.EVENT_TYPE.roomErrorNotice)
- The event is triggered to dispatch error message notifications
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name:TK.EVENT_TYPE.roomErrorNotice |
message |
Object |
Notification information |
Parameter name |
Type |
Description |
code |
Number |
Error status code, refer to ERROR message notification error codes |
info |
Object |
Supplementary information, used to provide additional explanations for the relevant status codes |
| const onRoomErrorNotice = data => {
console.log("room event type: ", data.type);
console.log("room error notice info: ", data.message)
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomErrorNotice, onRoomErrorNotice)
|
INFO message notification(TK.EVENT_TYPE.roomInfoNotice)
- The event is triggered to dispatch info message notifications
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name: TK.EVENT_TYPE.roomInfoNotice |
message |
Object |
Notification information |
Parameter name |
Type |
Description |
code |
Number |
Error status code, refer to INFO message notification status codes |
info |
Object |
Supplementary information, used to provide additional explanations for the relevant status codes |
| const onRoomInfoNotice = data => {
console.log("room event type: ", data.type);
console.log("room info notice info: ", data.message)
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomInfoNotice, onRoomInfoNotice)
|
Warning message notification(TK.EVENT_TYPE.roomWarnNotice)
- The event is triggered to dispatch warn message notifications
- Event data:
Parameter name |
Type |
Description |
type |
String |
Event name: TK.EVENT_TYPE.roomWarnNotice |
message |
Object |
Notification information |
Parameter name |
Type |
Description |
code |
Number |
Error status code, refer to WARN message notification status codes |
info |
Object |
Supplementary information, used to provide additional explanations for the relevant status codes |
| const onRoomInfoNotice = data => {
console.log("room event type: ", data.type);
console.log("room info notice info: ", data.message)
}
dispatcher.addEventListener(TK.EVENT_TYPE.roomInfoNotice, onRoomInfoNotice)
|