Просмотр исходного кода

feat: Introduces connection event for custom properties. (#2493)

* feat: Introduces connection event for custom properties.

Used for shard and region values coming from the backend.

* squash: Update JitsiConnectionEvents.ts

* squash: Update JitsiConnectionEvents.ts
release-8443
Дамян Минков 1 год назад
Родитель
Сommit
5237dbfeaa
Аккаунт пользователя с таким Email не найден
3 измененных файлов: 22 добавлений и 1 удалений
  1. 3
    0
      JitsiConnectionEvents.spec.ts
  2. 8
    1
      JitsiConnectionEvents.ts
  3. 11
    0
      modules/xmpp/xmpp.js

+ 3
- 0
JitsiConnectionEvents.spec.ts Просмотреть файл

@@ -10,6 +10,7 @@ describe( "/JitsiConnectionEvents members", () => {
10 10
         CONNECTION_REDIRECTED,
11 11
         WRONG_STATE,
12 12
         DISPLAY_NAME_REQUIRED,
13
+        PROPERTIES_UPDATED,
13 14
         JitsiConnectionEvents,
14 15
         ...others
15 16
     } = exported;
@@ -21,6 +22,7 @@ describe( "/JitsiConnectionEvents members", () => {
21 22
         expect( CONNECTION_REDIRECTED ).toBe( 'connection.redirected' );
22 23
         expect( WRONG_STATE ).toBe( 'connection.wrongState' );
23 24
         expect( DISPLAY_NAME_REQUIRED ).toBe( 'connection.display_name_required' );
25
+        expect( PROPERTIES_UPDATED ).toBe( 'connection.propertiesUpdated' );
24 26
 
25 27
         expect( JitsiConnectionEvents ).toBeDefined();
26 28
 
@@ -30,6 +32,7 @@ describe( "/JitsiConnectionEvents members", () => {
30 32
         expect( JitsiConnectionEvents.CONNECTION_REDIRECTED ).toBe( 'connection.redirected' );
31 33
         expect( JitsiConnectionEvents.WRONG_STATE ).toBe( 'connection.wrongState' );
32 34
         expect( JitsiConnectionEvents.DISPLAY_NAME_REQUIRED ).toBe( 'connection.display_name_required' );
35
+        expect( JitsiConnectionEvents.PROPERTIES_UPDATED ).toBe( 'connection.propertiesUpdated' );
33 36
     } );
34 37
 
35 38
     it( "unknown members", () => {

+ 8
- 1
JitsiConnectionEvents.ts Просмотреть файл

@@ -50,7 +50,13 @@ export enum JitsiConnectionEvents {
50 50
      * joining the room.
51 51
      * There are cases like lobby room where display name is required.
52 52
      */
53
-    DISPLAY_NAME_REQUIRED = 'connection.display_name_required'
53
+    DISPLAY_NAME_REQUIRED = 'connection.display_name_required',
54
+
55
+    /**
56
+     * Indicates that the connection properties have been updated.
57
+     * @param properties {object} - All available connection properties (e.g. shard, region).
58
+     */
59
+    PROPERTIES_UPDATED = 'connection.propertiesUpdated'
54 60
 }
55 61
 
56 62
 // exported for backward compatibility
@@ -60,3 +66,4 @@ export const CONNECTION_FAILED = JitsiConnectionEvents.CONNECTION_FAILED;
60 66
 export const CONNECTION_REDIRECTED = JitsiConnectionEvents.CONNECTION_REDIRECTED;
61 67
 export const WRONG_STATE = JitsiConnectionEvents.WRONG_STATE;
62 68
 export const DISPLAY_NAME_REQUIRED = JitsiConnectionEvents.DISPLAY_NAME_REQUIRED;
69
+export const PROPERTIES_UPDATED = JitsiConnectionEvents.PROPERTIES_UPDATED;

+ 11
- 0
modules/xmpp/xmpp.js Просмотреть файл

@@ -1110,5 +1110,16 @@ export default class XMPP extends Listenable {
1110 1110
         }
1111 1111
 
1112 1112
         this.sendDeploymentInfo = false;
1113
+
1114
+        const { region, shard } = aprops;
1115
+
1116
+        if (region || shard) {
1117
+            // avoids sending empty values
1118
+            this.eventEmitter.emit(JitsiConnectionEvents.PROPERTIES_UPDATED, JSON.parse(JSON.stringify({
1119
+                region,
1120
+                shard
1121
+            })));
1122
+        }
1123
+
1113 1124
     }
1114 1125
 }

Загрузка…
Отмена
Сохранить