forked from AgoraIO-Extensions/react-native-agora
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRtcEngine.js
28 lines (26 loc) · 784 Bytes
/
RtcEngine.js
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
import {
NativeModules,
findNodeHandle,
NativeAppEventEmitter
} from 'react-native';
const { Agora } = NativeModules
export default {
...Agora,
init(options = {}) {
this.listener && this.listener.remove();
Agora.init(options);
},
joinChannel(channelName = '00001', uid = 0){
Agora.joinChannel(channelName, uid)
},
eventEmitter(fnConf) {
//there are no `removeListener` for NativeAppEventEmitter & DeviceEventEmitter
this.listener && this.listener.remove();
this.listener = NativeAppEventEmitter.addListener('agoraEvent', event => {
fnConf[event['type']] && fnConf[event['type']](event);
});
},
removeEmitter() {
this.listener && this.listener.remove();
}
};