Bläddra i källkod

refactor. number convert

matrixbirds 4 år sedan
förälder
incheckning
69beb13077
4 ändrade filer med 40 tillägg och 43 borttagningar
  1. 4
    0
      lib/RtcEngine.native.d.ts
  2. 17
    20
      lib/RtcEngine.native.js
  3. 1
    1
      lib/RtcEngine.native.js.map
  4. 18
    22
      src/RtcEngine.native.ts

+ 4
- 0
lib/RtcEngine.native.d.ts Visa fil

@@ -319,6 +319,10 @@ declare class RtcEngine {
319 319
      * @ignore Uint32ToInt32
320 320
      */
321 321
     private static Uint32ToInt32;
322
+    /**
323
+     * @ignore Int32ToUint32
324
+     */
325
+    private static Int32ToUint32;
322 326
     /**
323 327
      * mute specified remote video stream.
324 328
      *

+ 17
- 20
lib/RtcEngine.native.js Visa fil

@@ -81,7 +81,7 @@ class RtcEngine {
81 81
             if (react_native_1.Platform.OS === 'android') {
82 82
                 const _uid = this.Uint32ToInt32(uid);
83 83
                 let result = yield Agora.getUserInfoByUid(_uid);
84
-                result.uid = this.Uint32ToInt32(result.uid);
84
+                result.uid = this.Int32ToUint32(result.uid);
85 85
                 return result;
86 86
             }
87 87
             return Agora.getUserInfoByUid(uid);
@@ -98,7 +98,7 @@ class RtcEngine {
98 98
         return tslib_1.__awaiter(this, void 0, void 0, function* () {
99 99
             if (react_native_1.Platform.OS === 'android') {
100 100
                 let result = yield Agora.getUserInfoByUserAccount(userAccount);
101
-                result.uid = this.Uint32ToInt32(result.uid);
101
+                result.uid = this.Int32ToUint32(result.uid);
102 102
                 return result;
103 103
             }
104 104
             return Agora.getUserInfoByUserAccount(userAccount);
@@ -217,14 +217,10 @@ class RtcEngine {
217 217
             'localUserRegistered'
218 218
         ].indexOf(eventType) != -1) {
219 219
             AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
220
-                const uint32_uid = new Uint32Array(1);
221
-                uint32_uid[0] = args.uid;
222
-                args.uid = uint32_uid[0];
220
+                args.uid = this.Int32ToUint32(args.uid);
223 221
                 // convert int32 streamId to uint32 
224 222
                 if (args.streamId) {
225
-                    const uint32_streamId = new Uint32Array(1);
226
-                    uint32_streamId[0] = args.streamId;
227
-                    args.streamId = uint32_streamId[0];
223
+                    args.streamId = this.Int32ToUint32(args.streamId);
228 224
                 }
229 225
                 listener(args);
230 226
             });
@@ -232,12 +228,8 @@ class RtcEngine {
232 228
         }
233 229
         if (['userInfoUpdated'].indexOf(eventType) != -1) {
234 230
             AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
235
-                const uint32_uid = new Uint32Array(1);
236
-                uint32_uid[0] = args.uid;
237
-                args.uid = uint32_uid[0];
238
-                const uint32_peer_uid = new Uint32Array(1);
239
-                uint32_peer_uid[0] = args.peer.uid;
240
-                args.peer.uid = uint32_peer_uid[0];
231
+                args.uid = this.Int32ToUint32(args.uid);
232
+                args.peer.uid = this.Int32ToUint32(args.peer.uid);
241 233
                 listener(args);
242 234
             });
243 235
             return;
@@ -245,9 +237,8 @@ class RtcEngine {
245 237
         if (['audioVolumeIndication'].indexOf(eventType) != -1) {
246 238
             AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
247 239
                 args.speakers.map((speaker) => {
248
-                    const uint32_uid = new Uint32Array(1);
249
-                    uint32_uid[0] = speaker.uid;
250
-                    return Object.assign({}, speaker, { uid: uint32_uid[0] });
240
+                    const uid = this.Int32ToUint32(speaker.uid);
241
+                    return Object.assign({}, speaker, { uid });
251 242
                 });
252 243
                 listener(args);
253 244
             });
@@ -260,9 +251,7 @@ class RtcEngine {
260 251
             'videoTransportStatsOfUid',
261 252
         ].indexOf(eventType) != -1) {
262 253
             AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
263
-                const uint32_uid = new Uint32Array(1);
264
-                uint32_uid[0] = args.stats.uid;
265
-                args.stats.uid = uint32_uid[0];
254
+                args.stats.uid = this.Int32ToUint32(args.stats.uid);
266 255
                 listener(args);
267 256
             });
268 257
             return;
@@ -469,6 +458,14 @@ class RtcEngine {
469 458
         int32[0] = num;
470 459
         return int32[0];
471 460
     }
461
+    /**
462
+     * @ignore Int32ToUint32
463
+     */
464
+    static Int32ToUint32(num) {
465
+        const uint32 = new Uint32Array(1);
466
+        uint32[0] = num;
467
+        return uint32[0];
468
+    }
472 469
     /**
473 470
      * mute specified remote video stream.
474 471
      *

+ 1
- 1
lib/RtcEngine.native.js.map
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 18
- 22
src/RtcEngine.native.ts Visa fil

@@ -118,7 +118,7 @@ class RtcEngine {
118 118
         if (Platform.OS === 'android') {
119 119
             const _uid = this.Uint32ToInt32(uid);
120 120
             let result = await Agora.getUserInfoByUid(_uid);
121
-            result.uid = this.Uint32ToInt32(result.uid);
121
+            result.uid = this.Int32ToUint32(result.uid);
122 122
             return result;
123 123
         }
124 124
         return Agora.getUserInfoByUid(uid);
@@ -134,7 +134,7 @@ class RtcEngine {
134 134
     public static async getUserInfoByUserAccount(userAccount: string): Promise<AgoraUserInfo> {
135 135
         if (Platform.OS === 'android') {
136 136
             let result = await Agora.getUserInfoByUserAccount(userAccount);
137
-            result.uid = this.Uint32ToInt32(result.uid);
137
+            result.uid = this.Int32ToUint32(result.uid);
138 138
             return result;
139 139
         }
140 140
         return Agora.getUserInfoByUserAccount(userAccount);
@@ -253,15 +253,10 @@ class RtcEngine {
253 253
             'localUserRegistered'
254 254
         ].indexOf(eventType) != -1) {
255 255
             AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
256
-                const uint32_uid = new Uint32Array(1);
257
-                uint32_uid[0] = args.uid;
258
-                args.uid = uint32_uid[0];
259
-
256
+                args.uid = this.Int32ToUint32(args.uid);
260 257
                 // convert int32 streamId to uint32 
261 258
                 if(args.streamId) {
262
-                    const uint32_streamId = new Uint32Array(1);
263
-                    uint32_streamId[0] = args.streamId;
264
-                    args.streamId = uint32_streamId[0];
259
+                    args.streamId = this.Int32ToUint32(args.streamId);
265 260
                 }
266 261
                 listener(args);
267 262
             });
@@ -270,13 +265,8 @@ class RtcEngine {
270 265
 
271 266
         if (['userInfoUpdated'].indexOf(eventType) != -1) {
272 267
             AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
273
-                const uint32_uid = new Uint32Array(1);
274
-                uint32_uid[0] = args.uid;
275
-                args.uid = uint32_uid[0];
276
-
277
-                const uint32_peer_uid = new Uint32Array(1);
278
-                uint32_peer_uid[0] = args.peer.uid;
279
-                args.peer.uid = uint32_peer_uid[0];
268
+                args.uid = this.Int32ToUint32(args.uid);
269
+                args.peer.uid = this.Int32ToUint32(args.peer.uid);
280 270
                 listener(args);
281 271
             });
282 272
             return;
@@ -285,11 +275,10 @@ class RtcEngine {
285 275
         if (['audioVolumeIndication'].indexOf(eventType) != -1) {
286 276
             AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
287 277
                 args.speakers.map((speaker: any) => {
288
-                    const uint32_uid = new Uint32Array(1);
289
-                    uint32_uid[0] = speaker.uid;
278
+                    const uid = this.Int32ToUint32(speaker.uid);
290 279
                     return {
291 280
                         ...speaker,
292
-                        uid: uint32_uid[0]
281
+                        uid
293 282
                     }
294 283
                 })
295 284
                 listener(args);
@@ -304,9 +293,7 @@ class RtcEngine {
304 293
             'videoTransportStatsOfUid',   
305 294
         ].indexOf(eventType) != -1) {
306 295
             AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
307
-                const uint32_uid = new Uint32Array(1);
308
-                uint32_uid[0] = args.stats.uid;
309
-                args.stats.uid = uint32_uid[0];
296
+                args.stats.uid = this.Int32ToUint32(args.stats.uid);
310 297
                 listener(args);
311 298
             });
312 299
             return;
@@ -536,6 +523,15 @@ class RtcEngine {
536 523
         return int32[0];
537 524
     }
538 525
 
526
+    /**
527
+     * @ignore Int32ToUint32
528
+     */
529
+    private static Int32ToUint32(num: number) {
530
+        const uint32 = new Uint32Array(1);
531
+        uint32[0] = num;
532
+        return uint32[0];
533
+    }
534
+
539 535
     /**
540 536
      * mute specified remote video stream.
541 537
      *