Sfoglia il codice sorgente

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 anno fa
parent
commit
5237dbfeaa
Nessun account collegato all'indirizzo email del committer
3 ha cambiato i file con 22 aggiunte e 1 eliminazioni
  1. 3
    0
      JitsiConnectionEvents.spec.ts
  2. 8
    1
      JitsiConnectionEvents.ts
  3. 11
    0
      modules/xmpp/xmpp.js

+ 3
- 0
JitsiConnectionEvents.spec.ts Vedi File

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

+ 8
- 1
JitsiConnectionEvents.ts Vedi File

50
      * joining the room.
50
      * joining the room.
51
      * There are cases like lobby room where display name is required.
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
 // exported for backward compatibility
62
 // exported for backward compatibility
60
 export const CONNECTION_REDIRECTED = JitsiConnectionEvents.CONNECTION_REDIRECTED;
66
 export const CONNECTION_REDIRECTED = JitsiConnectionEvents.CONNECTION_REDIRECTED;
61
 export const WRONG_STATE = JitsiConnectionEvents.WRONG_STATE;
67
 export const WRONG_STATE = JitsiConnectionEvents.WRONG_STATE;
62
 export const DISPLAY_NAME_REQUIRED = JitsiConnectionEvents.DISPLAY_NAME_REQUIRED;
68
 export const DISPLAY_NAME_REQUIRED = JitsiConnectionEvents.DISPLAY_NAME_REQUIRED;
69
+export const PROPERTIES_UPDATED = JitsiConnectionEvents.PROPERTIES_UPDATED;

+ 11
- 0
modules/xmpp/xmpp.js Vedi File

1110
         }
1110
         }
1111
 
1111
 
1112
         this.sendDeploymentInfo = false;
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
 }

Loading…
Annulla
Salva