本文介绍 TUIRoomKit 组件会议状态回调的使用。
会议状态监听
如果您的业务需要监听会议的状态,例如会议开始、结束等会议过程中的事件,可以参见如下代码:
ConferenceDefine.ConferenceObserver observer = new ConferenceDefine.ConferenceObserver() {
@Override
public void onConferenceStarted(TUIRoomDefine.RoomInfo roomInfo, TUICommonDefine.Error error, String message) {
}
@Override
public void onConferenceJoined(TUIRoomDefine.RoomInfo roomInfo, TUICommonDefine.Error error, String message) {
}
@Override
public void onConferenceExisted(String roomId) {
}
@Override
public void onConferenceFinished(String roomId) {
}
};
ConferenceSession.sharedInstance().addObserver(observer);
val observer: ConferenceObserver = object : ConferenceObserver() {
override fun onConferenceStarted(roomInfo: TUIRoomDefine.RoomInfo?, error: TUICommonDefine.Error?, message: String?) {
}
override fun onConferenceJoined(roomInfo: TUIRoomDefine.RoomInfo?, error: TUICommonDefine.Error?, message: String?) {
}
override fun onConferenceExisted(roomId: String?) {
}
override fun onConferenceFinished(roomId: String?) {
}
}
ConferenceSession.sharedInstance().addObserver(observer)
class EnterRoomViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
ConferenceSession.sharedInstance.addObserver(observer: self)
}
}
extension EnterRoomViewController: ConferenceObserver {
func onConferenceStarted(roomInfo: TUIRoomInfo, error: TUIError, message: String) {
}
func onConferenceJoined(roomInfo: TUIRoomInfo, error: TUIError, message: String) {
}
func onConferenceFinished(conferenceId: String) {
}
func onConferenceExited(conferenceId: String) {
}
}
@interface EnterRoomViewController () <ConferenceObserver>
@end
@implementation EnterRoomViewController
- (void)viewDidLoad {
[super viewDidLoad];
[[ConferenceSession sharedInstance] addObserver:self];
}
#pragma mark - ConferenceObserver
- (void)onConferenceStartedWithRoomInfo:(TUIRoomInfo *)roomInfo error:(TUIError *)error message:(NSString *)message {
}
- (void)onConferenceJoinedWithRoomInfo:(TUIRoomInfo *)roomInfo error:(TUIError *)error message:(NSString *)message {
}
- (void)onConferenceFinishedWithConferenceId:(NSString *)conferenceId {
}
- (void)onConferenceExitedWithConferenceId:(NSString *)conferenceId {
}
@end
本页内容是否解决了您的问题?