설명 없음

RtcEngine.native.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const react_native_1 = require("react-native");
  4. const { Agora } = react_native_1.NativeModules;
  5. const AgoraEventEmitter = new react_native_1.NativeEventEmitter(Agora);
  6. /**
  7. * @class RtcEngine
  8. */
  9. const RtcEngine = Object.assign({}, Agora, { eventTypes: new Set(),
  10. /**
  11. * init agora rtc engine and begin subscribe event immediately
  12. * @param options: Option
  13. */
  14. init(options) {
  15. Agora.init(options);
  16. },
  17. /**
  18. * join channel
  19. * @param channelName String for channel name
  20. * @param uid Number user id is optional
  21. * @param token String secure token
  22. * @param info Object extra info
  23. * @return Promise
  24. */
  25. joinChannel(channelName, uid, token, info) {
  26. return Agora.joinChannel({ channelName, uid, token, info });
  27. },
  28. /**
  29. * on - add event listener for react native event
  30. * @param eventType String
  31. * @param eventHandler Function
  32. */
  33. on(eventType, listener) {
  34. this.eventTypes.add(eventType);
  35. AgoraEventEmitter.addListener(eventType, listener);
  36. },
  37. /**
  38. * off - remove event listener for react native event
  39. * @param eventType
  40. * @param listener
  41. */
  42. off(eventType) {
  43. AgoraEventEmitter.removeAllListeners(eventType);
  44. this.eventTypes.delete(eventType);
  45. },
  46. /**
  47. * removeAllListeners
  48. */
  49. removeAllListeners() {
  50. for (let eventType of this.eventTypes) {
  51. this.off(eventType);
  52. }
  53. this.eventTypes.clear();
  54. },
  55. /**
  56. * destroy AgoraRtcEngine
  57. */
  58. destroy() {
  59. Agora.destroy();
  60. },
  61. /**
  62. * getSdkVersion
  63. * @param callback Function
  64. */
  65. getSdkVersion(callback) {
  66. Agora.getSdkVersion().then(callback);
  67. } });
  68. exports.default = RtcEngine;
  69. //# sourceMappingURL=RtcEngine.native.js.map