对应文件 tkroommanager_oc.h
shareInstance
-
简要描述
创建一个 TKRoomManager 单例对象,必须通过此接口创建对象。
-
函数原型
+ (instancetype)shareInstance;
-
方法示例
1 2 3 4 5 6 7 8 9 10 11 12
@interface RoomController : NSObject @property (strong, nonatomic) TKRoomManager *roomMgr; @end @implementation RoomController -(instancetype)init { self = [super init]; if (self) { _roomMgr = [TKRoomManager shareInstance]; } return self; } @end
destory
-
简要描述
销毁 TKRoomManager 单例对象,必须调用此接口。
-
函数原型
+ (void)destory;
-
方法示例
1
[TKRoomManager destory];
getSdkVersion
initWithAppKey
-
简要描述:
设置AppID,需要调用此接口初始化房间信息 使用 authKey 方式进入房间,需要传入 appKey,可在企业后台中查找appKey值 使用 token 方式进入教室,需要在 optional 中传入 TKRoomSettingOptionalCompanyDomain字段(公司域名)
-
函数原型
1
-(int)initWithAppKey:(NSString *)appKey options:(NSDictionary *)options;
-
参数
参数 说明 appKey 为企业authkey (企业注册时获得的 authkey) options 房间扩展信息,可根据自身的需求,在 TKRoomDefines.h 文件中查看 init初始化 定义的相关设置字段 -
方法示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
-(instancetype)init { self = [super init]; if (self) { _roomMgr = [TKRoomManager shareInstance]; NSArray *cachesPathArr = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); NSString *cachesPath = cachesPathArr.firstObject; NSString *logPath = [cachesPath stringByAppendingPathComponent:@"logs"]; [TKRoomManager setLogLevel:TKLogLevelInfo logPath:logPath debugToConsole:YES]; // authKey 方式进房间 [_roomMgr initWithAppKey:kAppkey optional:@{TKRoomSettingOptionalSecureSocket:@(YES), TKRoomSettingOptionalPrivatePort : @(443), TKRoomSettingOptionalWhiteBoardNotify: @(NO) }]; // token 方式进房间 [_roomMgr initWithAppKey:kAppkey optional:@{TKRoomSettingOptionalSecureSocket:@(YES), TKRoomSettingOptionalPrivatePort : @(443), TKRoomSettingOptionalWhiteBoardNotify: @(NO) TKRoomSettingOptionalCompanyDomain : @"companyDomain" }]; } return self; }
getInterface
-
简要描述
获取实例化的对象
-
函数原型
- (id)getInterface:(TKInterfaceType)interfaceID;
-
参数
参数 说明 interfaceID 对象枚举类型TKInterfaceType
registerRoomDelegate
-
简要描述:
注册房间 TKRoomManagerDelegate 代理,用以接受房间信息回调。
-
函数原型
1
-(void)registerRoomDelegate:(id<TKRoomManagerDelegate>)roomDelegate;
- 使用
使用之前需要选获取SDK实例对象,并且调用
initWithAppKey()
初始化SDK1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
@interface RoomController : NSObject<TKRoomManagerDelegate> @property (strong, nonatomic) TKRoomManager *roomMgr; @end @implementation RoomController -(instancetype)init { self = [super init]; if (self) { _roomMgr = [TKRoomManager instance]; NSArray *cachesPathArr = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); NSString *cachesPath = cachesPathArr.firstObject; NSString *logPath = [cachesPath stringByAppendingPathComponent:@"logs"]; [TKRoomManager setLogLevel:TKLogLevelInfo logPath:logPath debugToConsole:YES]; // authKey 方式进房间 [_roomMgr initWithAppKey:kAppkey optional:@{TKRoomSettingOptionalSecureSocket:@(YES), TKRoomSettingOptionalPrivatePort : @(443), TKRoomSettingOptionalWhiteBoardNotify: @(NO) }]; // token 方式进房间 [_roomMgr initWithAppKey:kAppkey optional:@{TKRoomSettingOptionalSecureSocket:@(YES), TKRoomSettingOptionalPrivatePort : @(443), TKRoomSettingOptionalWhiteBoardNotify: @(NO) TKRoomSettingOptionalCompanyDomain : @"companyDomain" }]; [_roomMgr registerRoomManagerDelegate:self]; } return self; } @end
registerMediaDelegate
-
简要描述:
设置音视频数据 TKMediaFrameDelegate 的代理,可以接受到本地和远端音视频数据的回调。
-
函数原型
1
-(void)registerMediaDelegate:(id<TKMediaFrameDelegate>)mediaDelegate;
-
使用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
@interface RoomController : NSObject<TKRoomManagerDelegate,TKMediaFrameDelegate> @property (strong, nonatomic) TKRoomManager *roomMgr; @end @implementation RoomController -(instancetype)init { self = [super init]; if (self) { _roomMgr = [TKRoomManager instance]; NSArray *cachesPathArr = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); NSString *cachesPath = cachesPathArr.firstObject; NSString *logPath = [cachesPath stringByAppendingPathComponent:@"logs"]; [TKRoomManager setLogLevel:TKLogLevelInfo logPath:logPath debugToConsole:YES]; // authKey 方式进房间 [_roomMgr initWithAppKey:kAppkey optional:@{TKRoomSettingOptionalSecureSocket:@(YES), TKRoomSettingOptionalPrivatePort : @(443), TKRoomSettingOptionalWhiteBoardNotify: @(NO) }]; // token 方式进房间 [_roomMgr initWithAppKey:kAppkey optional:@{TKRoomSettingOptionalSecureSocket:@(YES), TKRoomSettingOptionalPrivatePort : @(443), TKRoomSettingOptionalWhiteBoardNotify: @(NO) TKRoomSettingOptionalCompanyDomain : @"companyDomain" }]; [_roomMgr registerRoomManagerDelegate:self]; [_roomMgr registerMediaDelegate:self]; } return self; }