アンカー接続
Description of the Feature
The connection feature is a real-time interactive communication method, customized for anchors. It enables anchors from different rooms to interact and communicate in real-time during the livestream. TUILiveKit's connection feature supports up to nine people in a single room simultaneously. It provides strong technical support for various scenarios such as anchor interaction, knowledge sharing, cultural exchange, and e-commerce training. It offers diverse interactive methods for anchors and enriches the viewing experience for the audience, creating more surprises and value for both parties, and making livestreams more attractive.
Two-person connection | Multiple people connection |
| |
Access Process
Anchor Connection Process
The TUILiveKit anchor connection feature is mainly implemented based on LiveCoreView. You can use the following API to complete the anchor connection feature. Here is an example of connection between Anchor A and Anchor B.
Note:
The following are active call methods provided by LiveCoreView.
All callback methods refer to the callback methods in the ConnectionObserver object set by LiveCoreView.
Anchor A initiates the connection
Anchor A initiates the connection by calling
requestCrossRoomConnection
and passing the room ID of anchor B in the roomId parameter.val roomId = "anchorBRoomId"mLiveViewList.requestCrossRoomConnection(roomId, 10, null)
String roomId = "anchorBRoomId";mLiveViewList.requestCrossRoomConnection(roomId, 10, null);
let roomId = "anchorRoomId"liveCoreView.requestCrossRoomConnection(roomId: roomId, timeOut: 60) {} onError: { code, message in}
NSString *roomId = @"anchorRoomId";[liveCoreView requestCrossRoomConnection:roomIdtimeOut:60onSuccess:^(void) {} onError:^(NSInteger code, NSString * _Nonnull message) {}];
Anchor A can receive the request acceptance callback through
onCrossRoomConnectionAccepted
.Anchor B receives the connection request
Anchor B receives the connection request callback through
onCrossRoomConnectionRequest
.override fun onCrossRoomConnectionRequest(inviterUser: UserInfo) {Log.i(TAG, "Received a connection request from anchor A's room:${inviterUser.userId}")}
@Overridepublic void onCrossRoomConnectionRequest(LiveStreamDefine.RoomInfo roomInfo) {Log.i(TAG, "Received a connection request from anchor A's room:" + roomInfo.roomId);}
func onCrossRoomConnectionRequest(hostUser: TUIConnectionUser) {print("Received a connection request from anchor A's room:\(hostUser.userId)")}
- (void)onCrossRoomConnectionRequest:(TUIConnectionUser *)hostUser {NSLog(@"Received a connection request from anchor A's room:%@", hostUser.userId);}
Anchor B responds to the connection request by calling
respondToCrossRoomConnection
.liveCoreView.respondToCrossRoomConnection(roomId, true, null)
liveCoreView.respondToCrossRoomConnection(roomId, true, null);
liveCoreView.respondToCrossRoomConnection(roomId: roomId, isAccepted: true) {} onError: { code, message in}
[liveCoreView respondToCrossRoomConnection:roomIdisAccepted:trueonSuccess:^(void) {} onError:^(NSInteger code, NSString * _Nonnull message) {}];
Anchor A, anchor B, and the audience in the room receive the
onConnectedRoomsUpdated
callback and get notified of the changes in the connection list. override fun onConnectedRoomsUpdated(inviterUser: UserInfo) {Log.i(TAG, "The anchor connection room list has been updated")}
@Overridepublic void onConnectedRoomsUpdated(List<LiveStreamDefine.RoomInfo> roomList) {Log.i(TAG, "The anchor connection room list has been updated");}
func onConnectedRoomsUpdated(hostUserList: [TUIConnectionUser]) {print("The anchor connection room list has been updated")}
- (void)onConnectedRoomsUpdated:(NSArray<TUIConnectionUser *> *)hostUserList {NSLog(@"The anchor connection room list has been updated");}
Exit connection process
Anchor B exits the connection by calling terminateCrossRoomConnection
public void disconnect(TUIRoomDefine.ActionCallback callback) {mTUILiveConnectionManager.disconnect(callback);}
liveCoreView.terminateIntraRoomConnection()
liveCoreView.terminateCrossRoomConnection()
[liveCoreView terminateCrossRoomConnection];
Note:
The connection feature is implemented based on LiveCoreView. If you need to extend the connection feature, please refer to the LiveCoreView documentation.
Anchor connection sequence diagram