400-881-9892

文档中心

官方文档,可查阅产品介绍、快速入门、用户指南、开发指南、API参考、SDK参考、帮助等信息。

文档中心 互动课堂

Large-scale room

    Large-scale room

    1.It is possible to create large-scale rooms in the background.

    2.When the number of users in a one-to-many room reaches 100, the room will automatically be upgraded to a large room. You can monitor the msgName in the - (void)roomManagerOnRemotePubMsgWithMsgID:(NSString )msgID msgName:(NSString )msgName data:(NSObject )data fromID:(NSString )fromID inList:(BOOL)inlist ts:(long)ts callback. If msgName is "BigRoom", it indicates that the room has been upgraded to a large room.

    3.The following interfaces are effective only when called in the context of a large room.

    getRoomUserWithPeerId

    • Brief description

    In a large room, retrieve information of a specified user

    • Interface name

    - (int)getRoomUserWithPeerId:(NSString *)peerID callback:(void (^)(TKRoomUser *_Nullable user, NSError *_Nullable error))callback;

    • Parameter
    Parameter Name Required Type Description
    peerID Yes NSString User ID
    callback Yes (void (^)(TKRoomUser _Nullable user, NSError _Nullable error) Callback for retrieved user information
    • Method Example
    1
    2
    3
    4
        [_roomMgr getRoomUserWithPeerId:@"adc123456"
                               callback:^(TKRoomUser * _Nullable user, NSError * _Nullable error) {
              NSLog(@"用户ID = %@, 昵称 = %@", user.peerID, user.nickName);
        }];
    
    • Return Value Description
    Type Description
    int Return the playback audio identifier, the playback ID. If -1 is returned, it indicates playback failure.

    getRoomUserNumberWithRole

    • Brief description

    Get the number of specific users in a large room

    Search for users based on user roles, then match user nicknames, and return the count

    • Interface name
    1
    2
    3
    - (int)getRoomUserNumberWithRole:(NSArray * _Nullable)role
                                              search:(NSString * _Nullable)search
                                              callback:(void (^)(NSInteger num, NSError *error))callback;
    
    • Parameter
    Parameter Name Required Type Description
    role Yes NSArray Array of user roles
    search No NSString Search condition: Match user nickname
    callback Yes void (^)(NSInteger num, NSError *error) Request callback
    • Method Example
    1
    2
    3
    4
    5
        [_roomMgr getRoomUserNumberWithRole:[@2]
                                                        search:nil
                                                       callback:^(NSInteger num, NSError * _Nonnull error) {
            NSLog(@"num = %zd", num);
        }];
    
    • Return Value Description
    Type Description
    int Return the playback audio identifier, the playback ID. If -1 is returned, it indicates playback failure.

    getRoomUsersWithRole

    • Brief description

    In a large room, retrieve the list of users in the room

    Request users based on roles, in a paginated manner, to obtain a specific number of users.

    • Interface name
    1
    2
    3
    4
    5
    6
    - (int)getRoomUsersWithRole:(NSArray * _Nullable)role
                               startIndex:(NSInteger)start
                           maxNumber:(NSInteger)max
                                    search:(NSString * _Nullable)search
                                     order:(NSDictionary * _Nullable)order
                                callback:(void (^)(NSArray <TKRoomUser *>* _Nonnull users , NSError *error) )callback;
    
    • Parameter
    Parameter Name Required Type Description
    role No NSArray User role
    start Yes NSInteger Starting position, for example: 0, 20, 40, etc
    max Yes NSInteger Maximum number, for example: 20
    search No NSString Search condition: Match user nickname, can be nil
    order No NSDictionary Sorting condition: You can choose a user attribute as the sorting condition. asc for ascending order, dsc for descending order. For example: @"role" : @"asc", can be nil
    callback Yes void (^)(NSArray _Nonnull users , NSError error) Request callback
    • Method Example
    1
    2
    3
    4
    5
    6
    7
    8
        [_roomMgr getRoomUsersWithRole:nil
                            startIndex:0
                             maxNumber:20
                                search:nil
                                 order:@{@"role" : @"asc"}
                              callback:^(NSArray<TKRoomUser *> * _Nonnull users, NSError * _Nullable error) {
     
        }];
    
    • Return Value Description
    Type Description
    int Return the playback audio identifier, the playback ID. If -1 is returned, it indicates playback failure.

    batchChangeUserPropertyByIds

    • Brief description

    In a large room, change the attributes of specified users in batches

    • Interface name
    1
    2
    3
    4
    5
    6
    7
    8
    9
    - (int)batchChangeUserPropertyByIds:(NSArray<NSString *> *)peerIDs
                                          tellWhom:(NSString *)tellWhom
                                            property:(NSDictionary *)properties
                                     extensionJson:(NSDictionary * _Nullable)extensionJson
                                          completion:(completion_block _Nullable)completion;
    - (int)batchChangeUserPropertyByIds:(NSArray <NSString *>*)peerIDs
                                          tellWhom:(NSString *)tellWhom
                                            property:(NSDictionary *)properties
                                          completion:(completion_block _Nullable)completion;
    
    • Parameter
    Parameter Name Required Type Description
    peerIDs Yes NSArray User ID
    tellWhom Yes NSString The object to which this modification signal needs to be notified. Type is NSString, for details, see the relevant definitions in TKRoomDefines.h. It can be a specific user ID, indicating that the signal is sent only to that user
    properties Yes NSDictionary The attributes of the user being modified
    extensionJson No NSDictionary Extended information
    completion No completion_block Callback for the completion of the call
    • Method Example
    1
    2
    3
    4
    5
        [_roomMgr batchChangeUserPropertyByIds:@[@"adc123456", @"adc235641"]
                                                    tellWhom:TKRoomPubMsgTellAll
                                                        property:@{@"giftNumber" : @"1"}
                                                extensionJson:nil
                                                    completion:nil];
    
    • Return Value Description
    Type Description
    int Return the playback audio identifier, the playback ID. If -1 is returned, it indicates playback failure.

    changeUserPropertyByRole

    • Brief description

    In a large room, change the attributes of users with a specified role

    • Interface name
    1
    2
    3
    4
    5
    6
    7
    8
    9
    - (int)changeUserPropertyByRole:(NSArray *)roles
                                   tellWhom:(NSString *)tellWhom
                                     property:(NSDictionary *)properties
                              extensionJson:(NSDictionary * _Nullable)extensionJson
                                    completion:(completion_block _Nullable)completion;
    - (int)changeUserPropertyByRole:(NSArray *)roles
                                    tellWhom:(NSString *)tellWhom
                                     property:(NSDictionary *)properties
                                    completion:(completion_block _Nullable)completion;
    
    • Parameter
    Parameter Name Required Type Description
    roles Yes NSArray User role
    tellWhom No NSString The target to which this modification signal needs to be notified. Type is NSString. For details, refer to the relevant definitions in TKRoomDefines.h. It can be a specific user ID, indicating that the signal is sent only to that user.
    properties Yes NSDictionary The attributes of the user being modified
    extensionJson No NSDictionary Extended information
    completion Yes completion_block Callback for the completion of the call
    • Method Example
    1
    2
    3
    4
    5
        [_roomMgr changeUserPropertyByRole:@[@"1", @"2"]
                                  tellWhom:TKRoomPubMsgTellAll
                                  property:@{@"giftNumber" : @"1"}
                             extensionJson:nil
                                completion:nil];
    
    • Return Value Description
    Type Description
    int Return the playback audio identifier, the playback ID. If -1 is returned, it indicates playback failure.

    getUsersByProperty

    • Brief description

    In a large room, retrieve the list of users with the same attributes

    • Interface name

    - (int)getUsersByProperty:(NSDictionary *)properties callback:(void (^)(NSArray<TKRoomUser *> *list, NSError * _Nullable error))callback;

    • Parameter
    Parameter Name Required Type Description
    properties Yes NSDictionary User attributes, which must include the following fields: @"key" (attribute name), @"operator" (for details, refer to the enumeration definition of TKOperator in TKRoomDefines.h), and @"value" (the value corresponding to the attribute name). Optional fields include @"start", @"max", etc. For example: @{@"key" : @"publishstate", @"operator" : @"1", @"value" : @"0"}
    callback No void (^)(NSArray *list, NSError * _Nullable error) Callback
    • Method Example
    1
    2
    3
        [_roomMgr  getUsersByProperty:@{@"key" : @"publishstate", @"operator" : @1, @"value" : @0}
                             callback:^(NSArray<TKRoomUser *> * _Nonnull list, NSError * _Nullable error) {
        }];
    
    • Return Value Description
    Type Description
    int Return the playback audio identifier, the playback ID. If -1 is returned, it indicates playback failure.

    Notes

    For more return error codes, please refer to the error code descriptions in TKRoomErrorCode