RTC Room Engine
SDK to implement the audience co-guest feature.RTC Room Engine
supports the following seat management capabilities:RTC RoomEngine
SDK, you need to call the SDK login to ensure the subsequent features work properly.updateRoomSeatModeByAdmin
API to achieve this by passing the seat mode parameter seatMode
.TUISeatMode
.Enumeration value types | Meaning |
freeToTake | Request to speak does not require host approval and can be done directly. |
applyToTake | Request to speak requires host approval before speaking. |
updateRoomSeatModeByAdmin
API to achieve this by passing the seat mode parameter seatMode
.SeatMode
.Enumeration value types | Meaning |
FREE_TO_TAKE | Request to speak does not require host approval and can be done directly. |
APPLY_TO_TAKE | Request to speak requires host approval before speaking. |
import RTCRoomEnginelet seatMode: TUISeatMode = .applyToTake // Here, choose the apply-to-take mode. If you need to choose the free-to-take mode, change it to .freeToTakeTUIRoomEngine.sharedInstance().updateRoomSeatModeByAdmin(seatMode) {// Successfully set response configuration for speaking} onError: { code, message in// Failed to set response configuration for speaking}
TUIRoomDefine.SeatMode seatMode = TUIRoomDefine.SeatMode.APPLY_TO_TAKE; // Here, choose the apply-to-take mode. If you need to choose the free-to-take mode, change it to .freeToTakeTUIRoomEngine.sharedInstance().updateRoomSeatModeByAdmin(seatMode, new TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {// Successfully set response configuration for speaking}@Overridepublic void onError(TUICommonDefine.Error error, String message) {// Failed to set response configuration for speaking}});
getSeatList
API to get the current seat list information.import RTCRoomEngineTUIRoomEngine.sharedInstance().getSeatList { seatList in// Successfully got the microphone position list} onError: { code, messagea in// Failed to get the microphone position list}
TUIRoomEngine.sharedInstance().getSeatList(new TUIRoomDefine.GetSeatListCallback() {@Overridepublic void onSuccess(List<TUIRoomDefine.SeatInfo> list) {// Successfully got the microphone position list}@Overridepublic void onError(TUICommonDefine.Error error, String message) {// Failed to get the microphone position list}});
getSeatApplicationList
API to get the current seat applications information.import RTCRoomEngineTUIRoomEngine.sharedInstance().getSeatApplicationList { applications in// Successfully got the request to speak list} onError: { code, message in// Failed to get the request to speak list}
TUIRoomEngine.sharedInstance().getSeatApplicationList(new TUIRoomDefine.RequestListCallback() {@Overridepublic void onSuccess(List<TUIRoomDefine.Request> list) {// Successfully got the request to speak list}@Overridepublic void onError(TUICommonDefine.Error error, String message) {// Failed to get the request to speak list}});
takeSeat
API to request to take seat by passing two parameters: the index of the desired seat and the timeout duration.import RTCRoomEnginelet index = 1 // Please replace this with the seat number you want to apply for (context: code line content)let timeout = 30 // Please replace this with the timeout duration for your speaking request, in seconds. If set to 0, the SDK will not perform timeout detection or trigger timeout callbacks.TUIRoomEngine.sharedInstance().takeSeat(index, timeout: TimeInterval(timeout)) { requestId, userId in// Speaking request accepted} onRejected: { requestId, userId, message in// Speaking request rejected} onCancelled: { requestId, userId in// Speaking request canceled} onTimeout: { requestId, userId in// Speaking request timed out} onError: { requestId, userId, code, message in// Speaking request error}
int index = 1; // Please replace this with the seat number you want to apply for (context: code line content)int timeout = 30; // Replace this with the timeout duration for requesting to speak, in seconds. If set to 0, the SDK will not perform timeout detection or trigger timeout callbacksTUIRoomEngine.sharedInstance().takeSeat(index, timeout, new TUIRoomDefine.RequestCallback() {@Overridepublic void onAccepted(String requestId, String userId) {// Speaking request accepted}@Overridepublic void onRejected(String requestId, String userId, String message) {// Speaking request rejected}@Overridepublic void onCancelled(String requestId, String userId) {// Speaking request canceled}@Overridepublic void onTimeout(String requestId, String userId) {// Speaking request timed out}@Overridepublic void onError(String requestId, String userId, TUICommonDefine.Error error, String message) {// Speaking request error}});
RTC Room Engine
SDK through the addObserver
API, you will receive the onRequestReceived
callback when someone requests to speak. You can accept or reject the request through the responseRemoteRequest
API.func onRequestReceived(request: TUIRequest) {if request.requestAction == .takeSeat {let agreeToTakeSeat = true // If you want to reject the speaking request, set this to falseTUIRoomEngine.sharedInstance().responseRemoteRequest(request.requestId, agree: agreeToTakeSeat) {// Handle seat request successfully} onError: { code, message in// Handle seat request failed}}}
public void onRequestReceived(TUIRoomDefine.Request request) {if (TUIRoomDefine.RequestAction.REQUEST_TO_TAKE_SEAT == request.requestAction) {boolean agreeToTakeSeat = true; // If you want to reject the speaking request, set this to falseTUIRoomEngine.sharedInstance().responseRemoteRequest(request.requestId, agreeToTakeSeat, new TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {// Handle seat request successfully}@Overridepublic void onError(TUICommonDefine.Error error, String message) {// Handle seat request failed}});}}
leaveSeat
API.import RTCRoomEngineTUIRoomEngine.sharedInstance().leaveSeat {// Left the seat successfully} onError: { code, message in// Failed to leave the seat}
TUIRoomEngine.sharedInstance().leaveSeat(new TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {// Left the seat successfully}@Overridepublic void onError(TUICommonDefine.Error error, String message) {// Failed to leave the seat}});
moveToSeat
API, passing the parameter: the index of the seat you want to move to.import RTCRoomEnginelet targetIndex = 2TUIRoomEngine.sharedInstance().moveToSeat(targetSeatIndex: targetIndex) {// Successfully moved the seat} onError: { code, message in// Failed to move the seat}
int targetIndex = 2;TUIRoomEngine.sharedInstance().moveToSeat(targetIndex, new TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {// Successfully moved the seat}@Overridepublic void onError(TUICommonDefine.Error error, String message) {// Failed to move the seat}});
kickUserOffSeatByAdmin
API, passing the parameter: the user ID of the user you want to remove.import RTCRoomEnginelet targetIndex = -1 // Please set this value to -1, other values are meaninglesslet userId = "100001" // Please replace it with the user you want to removeTUIRoomEngine.sharedInstance().kickUserOffSeatByAdmin(targetIndex, userId: userId) {// Successfully removed a speaker} onError: { code, messagae in// Failed to remove a speaker}
int targetIndex = -1; // Please set this value to -1, other values are meaninglessString userId = "100001"; // Please replace it with the user you want to removeTUIRoomEngine.sharedInstance().kickUserOffSeatByAdmin(targetIndex, userId, new TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {// Successfully removed a speaker}@Overridepublic void onError(TUICommonDefine.Error error, String message) {// Failed to remove a speaker}});
takeUserOnSeatByAdmin
API, passing three parameters: the mic seat index you want to operate, the user ID of the user you want to invite, and the timeout duration.import RTCRoomEnginelet targetIndex = 4let timeout = 30 // Please replace this with the timeout duration for your speaking request, in seconds. If set to 0, the SDK will not perform timeout detection or trigger timeout callbacks.let targetUserId = "100002" // Please replace this with the user ID of the host you want to remove from the mic.TUIRoomEngine.sharedInstance().takeUserOnSeatByAdmin(tartgetIndex,userId: targetUserId,timeout: TimeInterval(timeout)) { requestId, userId in// Speaking invitation accepted} onRejected: { requestId, userId, message in// Speaking invitation rejected} onCancelled: { requestId, userId in// Seat-taking invitation timed out} onTimeout: { requestId, userId in// Speaking invitation canceled} onError: { requestId, userId, code, message in// Speaking invitation error}
int targetIndex = 4;int timeout = 30; // Replace this with the timeout duration for requesting to speak, in seconds. If set to 0, the SDK will not perform timeout detection or trigger timeout callbacksString targetUserId = "100002"; // Please replace this with the user ID of the host you want to remove from the mic.TUIRoomEngine.sharedInstance().takeUserOnSeatByAdmin(targetIndex, targetUserId, timeout, new TUIRoomDefine.RequestCallback() {@Overridepublic void onAccepted(String requestId, String userId) {// Speaking invitation accepted}@Overridepublic void onRejected(String requestId, String userId, String message) {// Speaking invitation rejected}@Overridepublic void onCancelled(String requestId, String userId) {// Seat-taking invitation timed out}@Overridepublic void onTimeout(String requestId, String userId) {// Speaking invitation canceled}@Overridepublic void onError(String requestId, String userId, TUICommonDefine.Error error, String message) {// Speaking invitation error}});
addObserver
API in the RTC Room Engine
SDK, you will receive the onRequestReceived
callback when someone invites you to speak. You can call responseRemoteRequest
to accept/reject the speaking invitation.func onRequestReceived(request: TUIRequest) {if request.requestAction == .remoteUserOnSeat {let agreeToTakeSeat = true // If you want to reject the speaking invitation, set this to falseTUIRoomEngine.sharedInstance().responseRemoteRequest(request.requestId,agree: agreeToTakeSeat) {// Handle seat invitation successfully} onError: { code, message in// Handle seat invitation failed}}}
public void onRequestReceived(TUIRoomDefine.Request request) {if (TUIRoomDefine.RequestAction.REQUEST_REMOTE_USER_ON_SEAT == request.requestAction) {boolean agreeToTakeSeat = true; // If you want to reject the seat invitation, set this to falseTUIRoomEngine.sharedInstance().responseRemoteRequest(request.requestId, agreeToTakeSeat, new TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {// Handle seat invitation successfully}@Overridepublic void onError(TUICommonDefine.Error error, String message) {// Handle seat invitation failed}});}}
lockSeat
API, passing two parameters: the index of the seat to be locked and the lock mode.TUISeatLockParams
) is as follows:Property Name | Field Description | Additional Notes | Data Type | Example |
lockSeat | Lock Microphone Position | Locking the corresponding seat prevents applications to take that seat. | Boolean value | True when the seat is locked. |
lockVideo | Lock the seat camera. | Locking the corresponding seat camera will stop the seat from publishing video streams. | Boolean value | false |
lockAudio | Lock the seat microphone. | Locking the corresponding seat camera will stop the seat from publishing audio streams. | Boolean value | True when the seat microphone is locked. |
lockSeat
API, passing two parameters: the index of the seat to be locked and the lock mode.SeatLockParams
) is as follows:Property Name | Field Description | Additional Notes | Data Type | Example |
lockSeat | Lock Microphone Position | Locking the corresponding seat prevents applications to take that seat. | Boolean value | True when the seat is locked. |
lockVideo | Lock the seat camera. | Locking the corresponding seat camera will stop the seat from publishing video streams. | Boolean value | false |
lockAudio | Lock the seat microphone. | Locking the corresponding seat camera will stop the seat from publishing audio streams. | Boolean value | True when the seat microphone is locked. |
lockSeatByAdmin
API:import RTCRoomEngine// Lock a seat.let lockSeatIndex = 5let lockSeatParam = TUISeatLockParams()lockSeatParam.lockSeat = trueTUIRoomEngine.sharedInstance().lockSeatByAdmin(lockSeatIndex,lockMode: lockSeatParam) {// Lock the seat successfully} onError: { code, message in// Failed to lock the seat}// Lock the seat microphonelet lockSeatAudioIndex = 6let lockSeatAudioParam = TUISeatLockParams()lockSeatAudioParam.lockAudio = trueTUIRoomEngine.sharedInstance().lockSeatByAdmin(lockSeatAudioIndex,lockMode: lockSeatAudioParam) {// Lock the seat microphone successfully} onError: { code, message in// Failed to lock the seat microphone}// Lock the seat cameralet lockSeatVideoIndex = 7let lockSeatVideoParam = TUISeatLockParams()lockSeatAudioParam.lockVideo = trueTUIRoomEngine.sharedInstance().lockSeatByAdmin(lockSeatVideoIndex,lockMode: lockSeatAudioParam) {// Lock seat camera successfully} onError: { code, message in// Lock seat camera failed}
// Lock a seat.int lockSeatIndex = 5;TUIRoomDefine.SeatLockParams lockSeatParam = new TUIRoomDefine.SeatLockParams();lockSeatParam.lockSeat = true;TUIRoomEngine.sharedInstance().lockSeatByAdmin(lockSeatIndex, lockSeatParam, new TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {// Lock the seat successfully}@Overridepublic void onError(TUICommonDefine.Error error, String message) {// Failed to lock the seat}});// Lock the seat microphoneint lockSeatAudioIndex = 6;TUIRoomDefine.SeatLockParams lockSeatAudioParam = new TUIRoomDefine.SeatLockParams();lockSeatAudioParam.lockAudio = true;TUIRoomEngine.sharedInstance().lockSeatByAdmin(lockSeatAudioIndex, lockSeatAudioParam, new TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {// Lock the seat microphone successfully}@Overridepublic void onError(TUICommonDefine.Error error, String message) {// Failed to lock the seat microphone}});// Lock the seat cameraint lockSeatVideoIndex = 7;TUIRoomDefine.SeatLockParams lockSeatVideoParam = new TUIRoomDefine.SeatLockParams();lockSeatAudioParam.lockVideo = true;TUIRoomEngine.sharedInstance().lockSeatByAdmin(lockSeatVideoIndex, lockSeatAudioParam, new TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {// Lock seat camera successfully}@Overridepublic void onError(TUICommonDefine.Error error, String message) {// Lock seat camera failed}});
RTC Room Engine
SDK by calling addObserver
to listen for seat-related callbacks.CoGuestController
as an example to become an observer:import RTCRoomEngineclass CoGuestController: NSObject, TUIRoomObserver { // Please replace it with your business class, this is just an exampleoverride init() {super.init()TUIRoomEngine.sharedInstance().addObserver(self)}deinit {TUIRoomEngine.sharedInstance().removeObserver(self)}// Triggered when the room mic mode changesfunc onRoomSeatModeChanged(roomId: String, seatMode: TUISeatMode) {// Room seat mode changed, current mode: seatMode}// Triggered when the mic list changesfunc onSeatListChanged(seatList: [TUISeatInfo], seated seatedList: [TUISeatInfo], left leftList: [TUISeatInfo]) {// Microphone position list changed, latest user list on mic: seatList, newly seated user list: seatedList, newly left user list: leftList}// Triggered when a request from another user is receivedfunc onRequestReceived(request: TUIRequest) {switch request.requestAction {case .takeSeat:// Received a seat request from request.userNamecase .remoteUserOnSeat:// Received a seat invitation from request.userNamedefault:break}}// Triggered when another user cancels the requestfunc onRequestCancelled(request: TUIRequest, operateUser: TUIUserInfo) {switch request.requestAction {case .takeSeat:// Seat request from request.userName was canceledcase .remoteUserOnSeat:// Seat invitation from request.userName was canceleddefault:break}}// Triggered when the request is handled by another admin/room ownerfunc onRequestProcessed(request: TUIRequest, operateUser: TUIUserInfo) {switch request.requestAction {case .takeSeat:// Seat request from request.userName was handled by operateUser.userNamecase .remoteUserOnSeat:// Seat invitation from request.userName was handled by operateUser.userNamedefault:break}}}
RTC Room Engine
SDK by calling addObserver
to listen for seat-related callbacks.CoGuestObserver
as an example to become an observer:class CoGuestObserver extends TUIRoomObserver { // Please replace it with your business class, this is just an exampleCoGuestObserver() {TUIRoomEngine.sharedInstance().addObserver(this);}// Triggered when the room mic mode changes@Overridepublic void onRoomSeatModeChanged(String roomId, TUIRoomDefine.SeatMode seatMode) {// Room seat mode changed, current mode: seatMode}// Triggered when the mic list changes@Overridepublic void onSeatListChanged(List<TUIRoomDefine.SeatInfo> seatList, List<TUIRoomDefine.SeatInfo> seatedList,List<TUIRoomDefine.SeatInfo> leftList) {// Microphone position list changed, latest user list on mic: seatList, newly seated user list: seatedList, newly left user list: leftList}// Triggered when a request from another user is received@Overridepublic void onRequestReceived(TUIRoomDefine.Request request) {switch (request.requestAction) {case REQUEST_TO_TAKE_SEAT:// Received a seat request from request.userNamecase REQUEST_REMOTE_USER_ON_SEAT:// Received a seat invitation from request.userNamedefault:break;}}// Triggered when another user cancels the request@Overridepublic void onRequestCancelled(TUIRoomDefine.Request request, TUIRoomDefine.UserInfo operateUser) {switch (request.requestAction) {case REQUEST_TO_TAKE_SEAT:// Seat request from request.userName was canceledcase REQUEST_REMOTE_USER_ON_SEAT:// Seat invitation from request.userName was canceleddefault:break;}}// Triggered when the request is handled by another admin/room owner@Overridepublic void onRequestProcessed(TUIRoomDefine.Request request, TUIRoomDefine.UserInfo operateUser) {switch (request.requestAction) {case REQUEST_TO_TAKE_SEAT:// Seat request from request.userName was handled by operateUser.userNamecase REQUEST_REMOTE_USER_ON_SEAT:// Seat invitation from request.userName was handled by operateUser.userNamedefault:break;}}}
Was this page helpful?