57 lines
1.1 KiB
Mathematica
57 lines
1.1 KiB
Mathematica
![]() |
//
|
||
|
// RTCManager.m
|
||
|
// xplan-ios
|
||
|
//
|
||
|
// Created by zu on 2021/10/19.
|
||
|
//
|
||
|
|
||
|
#import "RtcManager.h"
|
||
|
#import "AgoraRtcImpl.h"
|
||
|
|
||
|
@interface RtcManager()
|
||
|
|
||
|
@property (nonatomic, strong, readwrite) id<RtcDelegate> engine;
|
||
|
@property (nonatomic, assign) RtcEngineType engineType;
|
||
|
|
||
|
@end
|
||
|
|
||
|
@implementation RtcManager
|
||
|
|
||
|
+ (instancetype)sharedEngineWithType:(RtcEngineType)type {
|
||
|
static dispatch_once_t onceToken;
|
||
|
static RtcManager *instance = nil;
|
||
|
dispatch_once(&onceToken,^{
|
||
|
instance = [[self alloc] init];
|
||
|
});
|
||
|
[instance setEngineType:type];
|
||
|
return instance;
|
||
|
}
|
||
|
|
||
|
- (void) setEngineType:(RtcEngineType)type {
|
||
|
if (_engine && type != _engineType) {
|
||
|
[_engine exitChannel];
|
||
|
[_engine destory];
|
||
|
_engine = nil;
|
||
|
}
|
||
|
_engineType = type;
|
||
|
}
|
||
|
|
||
|
- (id<RtcDelegate>)engine {
|
||
|
if (!_engine) {
|
||
|
switch (_engineType) {
|
||
|
case RtcEngineType_Agora: {
|
||
|
_engine = [[AgoraRtcImpl alloc] init];
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
default: {
|
||
|
_engine = [[AgoraRtcImpl alloc] init];
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
return _engine;
|
||
|
}
|
||
|
|
||
|
@end
|