瀏覽代碼

feat: Moves redirected event to connection events.

release-8443
damencho 2 年之前
父節點
當前提交
1151f7cca3

+ 0
- 3
JitsiConferenceErrors.spec.ts 查看文件

23
         OFFER_ANSWER_FAILED,
23
         OFFER_ANSWER_FAILED,
24
         PASSWORD_NOT_SUPPORTED,
24
         PASSWORD_NOT_SUPPORTED,
25
         PASSWORD_REQUIRED,
25
         PASSWORD_REQUIRED,
26
-        REDIRECTED,
27
         RESERVATION_ERROR,
26
         RESERVATION_ERROR,
28
         VIDEOBRIDGE_NOT_AVAILABLE,
27
         VIDEOBRIDGE_NOT_AVAILABLE,
29
         JitsiConferenceErrors,
28
         JitsiConferenceErrors,
51
         expect( PASSWORD_NOT_SUPPORTED ).toBe( 'conference.passwordNotSupported' );
50
         expect( PASSWORD_NOT_SUPPORTED ).toBe( 'conference.passwordNotSupported' );
52
         expect( PASSWORD_REQUIRED ).toBe( 'conference.passwordRequired' );
51
         expect( PASSWORD_REQUIRED ).toBe( 'conference.passwordRequired' );
53
         expect( RESERVATION_ERROR ).toBe( 'conference.reservationError' );
52
         expect( RESERVATION_ERROR ).toBe( 'conference.reservationError' );
54
-        expect( REDIRECTED ).toBe( 'conference.redirected' );
55
         expect( VIDEOBRIDGE_NOT_AVAILABLE ).toBe( 'conference.videobridgeNotAvailable' );
53
         expect( VIDEOBRIDGE_NOT_AVAILABLE ).toBe( 'conference.videobridgeNotAvailable' );
56
 
54
 
57
         expect( JitsiConferenceErrors ).toBeDefined();
55
         expect( JitsiConferenceErrors ).toBeDefined();
76
         expect( JitsiConferenceErrors.PASSWORD_NOT_SUPPORTED ).toBe( 'conference.passwordNotSupported' );
74
         expect( JitsiConferenceErrors.PASSWORD_NOT_SUPPORTED ).toBe( 'conference.passwordNotSupported' );
77
         expect( JitsiConferenceErrors.PASSWORD_REQUIRED ).toBe( 'conference.passwordRequired' );
75
         expect( JitsiConferenceErrors.PASSWORD_REQUIRED ).toBe( 'conference.passwordRequired' );
78
         expect( JitsiConferenceErrors.RESERVATION_ERROR ).toBe( 'conference.reservationError' );
76
         expect( JitsiConferenceErrors.RESERVATION_ERROR ).toBe( 'conference.reservationError' );
79
-        expect( JitsiConferenceErrors.REDIRECTED ).toBe( 'conference.redirected' );
80
         expect( JitsiConferenceErrors.VIDEOBRIDGE_NOT_AVAILABLE ).toBe( 'conference.videobridgeNotAvailable' );
77
         expect( JitsiConferenceErrors.VIDEOBRIDGE_NOT_AVAILABLE ).toBe( 'conference.videobridgeNotAvailable' );
81
     } );
78
     } );
82
 
79
 

+ 1
- 7
JitsiConferenceErrors.ts 查看文件

105
      */
105
      */
106
     PASSWORD_REQUIRED = 'conference.passwordRequired',
106
     PASSWORD_REQUIRED = 'conference.passwordRequired',
107
 
107
 
108
-    /**
109
-     * The conference is redirected to a visitor node.
110
-     */
111
-    REDIRECTED = 'conference.redirected',
112
-
113
     /**
108
     /**
114
      * Indicates that reservation system returned error.
109
      * Indicates that reservation system returned error.
115
      */
110
      */
119
      * Indicates that there is no available videobridge.
114
      * Indicates that there is no available videobridge.
120
      */
115
      */
121
     VIDEOBRIDGE_NOT_AVAILABLE = 'conference.videobridgeNotAvailable'
116
     VIDEOBRIDGE_NOT_AVAILABLE = 'conference.videobridgeNotAvailable'
122
-};
117
+}
123
 
118
 
124
 // exported for backward compatibility
119
 // exported for backward compatibility
125
 export const AUTHENTICATION_REQUIRED = JitsiConferenceErrors.AUTHENTICATION_REQUIRED;
120
 export const AUTHENTICATION_REQUIRED = JitsiConferenceErrors.AUTHENTICATION_REQUIRED;
141
 export const OFFER_ANSWER_FAILED = JitsiConferenceErrors.OFFER_ANSWER_FAILED;
136
 export const OFFER_ANSWER_FAILED = JitsiConferenceErrors.OFFER_ANSWER_FAILED;
142
 export const PASSWORD_NOT_SUPPORTED = JitsiConferenceErrors.PASSWORD_NOT_SUPPORTED;
137
 export const PASSWORD_NOT_SUPPORTED = JitsiConferenceErrors.PASSWORD_NOT_SUPPORTED;
143
 export const PASSWORD_REQUIRED = JitsiConferenceErrors.PASSWORD_REQUIRED;
138
 export const PASSWORD_REQUIRED = JitsiConferenceErrors.PASSWORD_REQUIRED;
144
-export const REDIRECTED = JitsiConferenceErrors.REDIRECTED;
145
 export const RESERVATION_ERROR = JitsiConferenceErrors.RESERVATION_ERROR;
139
 export const RESERVATION_ERROR = JitsiConferenceErrors.RESERVATION_ERROR;
146
 export const VIDEOBRIDGE_NOT_AVAILABLE = JitsiConferenceErrors.VIDEOBRIDGE_NOT_AVAILABLE;
140
 export const VIDEOBRIDGE_NOT_AVAILABLE = JitsiConferenceErrors.VIDEOBRIDGE_NOT_AVAILABLE;

+ 0
- 4
JitsiConferenceEventManager.js 查看文件

225
         JitsiConferenceEvents.CONFERENCE_FAILED,
225
         JitsiConferenceEvents.CONFERENCE_FAILED,
226
         JitsiConferenceErrors.AUTHENTICATION_REQUIRED);
226
         JitsiConferenceErrors.AUTHENTICATION_REQUIRED);
227
 
227
 
228
-    this.chatRoomForwarder.forward(XMPPEvents.REDIRECTED,
229
-        JitsiConferenceEvents.CONFERENCE_FAILED,
230
-        JitsiConferenceErrors.REDIRECTED);
231
-
232
     this.chatRoomForwarder.forward(XMPPEvents.BRIDGE_DOWN,
228
     this.chatRoomForwarder.forward(XMPPEvents.BRIDGE_DOWN,
233
         JitsiConferenceEvents.CONFERENCE_FAILED,
229
         JitsiConferenceEvents.CONFERENCE_FAILED,
234
         JitsiConferenceErrors.VIDEOBRIDGE_NOT_AVAILABLE);
230
         JitsiConferenceErrors.VIDEOBRIDGE_NOT_AVAILABLE);

+ 4
- 1
JitsiConnectionEvents.spec.ts 查看文件

7
         CONNECTION_DISCONNECTED,
7
         CONNECTION_DISCONNECTED,
8
         CONNECTION_ESTABLISHED,
8
         CONNECTION_ESTABLISHED,
9
         CONNECTION_FAILED,
9
         CONNECTION_FAILED,
10
+        CONNECTION_REDIRECTED,
10
         WRONG_STATE,
11
         WRONG_STATE,
11
         DISPLAY_NAME_REQUIRED,
12
         DISPLAY_NAME_REQUIRED,
12
         JitsiConnectionEvents,
13
         JitsiConnectionEvents,
17
         expect( CONNECTION_DISCONNECTED ).toBe( 'connection.connectionDisconnected' );
18
         expect( CONNECTION_DISCONNECTED ).toBe( 'connection.connectionDisconnected' );
18
         expect( CONNECTION_ESTABLISHED ).toBe( 'connection.connectionEstablished' );
19
         expect( CONNECTION_ESTABLISHED ).toBe( 'connection.connectionEstablished' );
19
         expect( CONNECTION_FAILED ).toBe( 'connection.connectionFailed' );
20
         expect( CONNECTION_FAILED ).toBe( 'connection.connectionFailed' );
21
+        expect( CONNECTION_REDIRECTED ).toBe( 'connection.redirected' );
20
         expect( WRONG_STATE ).toBe( 'connection.wrongState' );
22
         expect( WRONG_STATE ).toBe( 'connection.wrongState' );
21
         expect( DISPLAY_NAME_REQUIRED ).toBe( 'connection.display_name_required' );
23
         expect( DISPLAY_NAME_REQUIRED ).toBe( 'connection.display_name_required' );
22
 
24
 
25
         expect( JitsiConnectionEvents.CONNECTION_DISCONNECTED ).toBe( 'connection.connectionDisconnected' );
27
         expect( JitsiConnectionEvents.CONNECTION_DISCONNECTED ).toBe( 'connection.connectionDisconnected' );
26
         expect( JitsiConnectionEvents.CONNECTION_ESTABLISHED ).toBe( 'connection.connectionEstablished' );
28
         expect( JitsiConnectionEvents.CONNECTION_ESTABLISHED ).toBe( 'connection.connectionEstablished' );
27
         expect( JitsiConnectionEvents.CONNECTION_FAILED ).toBe( 'connection.connectionFailed' );
29
         expect( JitsiConnectionEvents.CONNECTION_FAILED ).toBe( 'connection.connectionFailed' );
30
+        expect( JitsiConnectionEvents.CONNECTION_REDIRECTED ).toBe( 'connection.redirected' );
28
         expect( JitsiConnectionEvents.WRONG_STATE ).toBe( 'connection.wrongState' );
31
         expect( JitsiConnectionEvents.WRONG_STATE ).toBe( 'connection.wrongState' );
29
         expect( JitsiConnectionEvents.DISPLAY_NAME_REQUIRED ).toBe( 'connection.display_name_required' );
32
         expect( JitsiConnectionEvents.DISPLAY_NAME_REQUIRED ).toBe( 'connection.display_name_required' );
30
     } );
33
     } );
33
         const keys = Object.keys( others );
36
         const keys = Object.keys( others );
34
         expect( keys ).withContext( `Extra members: ${ keys.join( ", " ) }` ).toEqual( [] );
37
         expect( keys ).withContext( `Extra members: ${ keys.join( ", " ) }` ).toEqual( [] );
35
     } );
38
     } );
36
-} );
39
+} );

+ 7
- 1
JitsiConnectionEvents.ts 查看文件

34
      */
34
      */
35
     CONNECTION_FAILED = 'connection.connectionFailed',
35
     CONNECTION_FAILED = 'connection.connectionFailed',
36
 
36
 
37
+    /**
38
+     * The connection is redirected to a visitor node.
39
+     */
40
+    CONNECTION_REDIRECTED = 'connection.redirected',
41
+
37
     /**
42
     /**
38
      * Indicates that the performed action cannot be executed because the
43
      * Indicates that the performed action cannot be executed because the
39
      * connection is not in the correct state(connected, disconnected, etc.)
44
      * connection is not in the correct state(connected, disconnected, etc.)
46
      * There are cases like lobby room where display name is required.
51
      * There are cases like lobby room where display name is required.
47
      */
52
      */
48
     DISPLAY_NAME_REQUIRED = 'connection.display_name_required'
53
     DISPLAY_NAME_REQUIRED = 'connection.display_name_required'
49
-};
54
+}
50
 
55
 
51
 // exported for backward compatibility
56
 // exported for backward compatibility
52
 export const CONNECTION_DISCONNECTED = JitsiConnectionEvents.CONNECTION_DISCONNECTED;
57
 export const CONNECTION_DISCONNECTED = JitsiConnectionEvents.CONNECTION_DISCONNECTED;
53
 export const CONNECTION_ESTABLISHED = JitsiConnectionEvents.CONNECTION_ESTABLISHED;
58
 export const CONNECTION_ESTABLISHED = JitsiConnectionEvents.CONNECTION_ESTABLISHED;
54
 export const CONNECTION_FAILED = JitsiConnectionEvents.CONNECTION_FAILED;
59
 export const CONNECTION_FAILED = JitsiConnectionEvents.CONNECTION_FAILED;
60
+export const CONNECTION_REDIRECTED = JitsiConnectionEvents.CONNECTION_REDIRECTED;
55
 export const WRONG_STATE = JitsiConnectionEvents.WRONG_STATE;
61
 export const WRONG_STATE = JitsiConnectionEvents.WRONG_STATE;
56
 export const DISPLAY_NAME_REQUIRED = JitsiConnectionEvents.DISPLAY_NAME_REQUIRED;
62
 export const DISPLAY_NAME_REQUIRED = JitsiConnectionEvents.DISPLAY_NAME_REQUIRED;

+ 0
- 19
modules/xmpp/ChatRoom.js 查看文件

172
 
172
 
173
         this.eventsForwarder = new EventEmitterForwarder(this.xmpp.moderator, this.eventEmitter);
173
         this.eventsForwarder = new EventEmitterForwarder(this.xmpp.moderator, this.eventEmitter);
174
         this.eventsForwarder.forward(AuthenticationEvents.IDENTITY_UPDATED, AuthenticationEvents.IDENTITY_UPDATED);
174
         this.eventsForwarder.forward(AuthenticationEvents.IDENTITY_UPDATED, AuthenticationEvents.IDENTITY_UPDATED);
175
-        this.eventsForwarder.forward(XMPPEvents.REDIRECTED, XMPPEvents.REDIRECTED);
176
         this.eventsForwarder.forward(XMPPEvents.AUTHENTICATION_REQUIRED, XMPPEvents.AUTHENTICATION_REQUIRED);
175
         this.eventsForwarder.forward(XMPPEvents.AUTHENTICATION_REQUIRED, XMPPEvents.AUTHENTICATION_REQUIRED);
177
         this.eventsForwarder.forward(XMPPEvents.FOCUS_DISCONNECTED, XMPPEvents.FOCUS_DISCONNECTED);
176
         this.eventsForwarder.forward(XMPPEvents.FOCUS_DISCONNECTED, XMPPEvents.FOCUS_DISCONNECTED);
178
         this.eventsForwarder.forward(XMPPEvents.RESERVATION_ERROR, XMPPEvents.RESERVATION_ERROR);
177
         this.eventsForwarder.forward(XMPPEvents.RESERVATION_ERROR, XMPPEvents.RESERVATION_ERROR);
1593
         return this.role === 'moderator';
1592
         return this.role === 'moderator';
1594
     }
1593
     }
1595
 
1594
 
1596
-    /**
1597
-     * Redirected back.
1598
-     * @param iq The received iq.
1599
-     */
1600
-    onVisitorIQ(iq) {
1601
-        const visitors = $(iq).find('>visitors[xmlns="jitsi:visitors"]');
1602
-        const response = $(iq).find('promotion-response');
1603
-
1604
-        if (visitors.length && response.length
1605
-            && String(response.attr('allow')).toLowerCase() === 'true') {
1606
-            logger.warn('Redirected back to main room.');
1607
-
1608
-            this.eventEmitter.emit(
1609
-                XMPPEvents.REDIRECTED, undefined, visitors.attr('focusjid'), response.attr('username'));
1610
-        }
1611
-    }
1612
-
1613
     /**
1595
     /**
1614
      * Obtains the info about given media advertised (in legacy format) in the MUC presence of the participant
1596
      * Obtains the info about given media advertised (in legacy format) in the MUC presence of the participant
1615
      * identified by the given endpoint JID. This is for mantining interop with endpoints that do not support
1597
      * identified by the given endpoint JID. This is for mantining interop with endpoints that do not support
1833
 
1815
 
1834
         this.eventsForwarder.removeListeners(
1816
         this.eventsForwarder.removeListeners(
1835
             AuthenticationEvents.IDENTITY_UPDATED,
1817
             AuthenticationEvents.IDENTITY_UPDATED,
1836
-            XMPPEvents.REDIRECTED,
1837
             XMPPEvents.AUTHENTICATION_REQUIRED,
1818
             XMPPEvents.AUTHENTICATION_REQUIRED,
1838
             XMPPEvents.FOCUS_DISCONNECTED,
1819
             XMPPEvents.FOCUS_DISCONNECTED,
1839
             XMPPEvents.RESERVATION_ERROR);
1820
             XMPPEvents.RESERVATION_ERROR);

+ 3
- 1
modules/xmpp/moderator.js 查看文件

3
 import $ from 'jquery';
3
 import $ from 'jquery';
4
 import { $iq, Strophe } from 'strophe.js';
4
 import { $iq, Strophe } from 'strophe.js';
5
 
5
 
6
+import { CONNECTION_REDIRECTED } from '../../JitsiConnectionEvents';
6
 import FeatureFlags from '../flags/FeatureFlags';
7
 import FeatureFlags from '../flags/FeatureFlags';
7
 import Settings from '../settings/Settings';
8
 import Settings from '../settings/Settings';
8
 import Listenable from '../util/Listenable';
9
 import Listenable from '../util/Listenable';
61
         // availability.
62
         // availability.
62
         this.sipGatewayEnabled = false;
63
         this.sipGatewayEnabled = false;
63
 
64
 
65
+        this.xmpp = xmpp;
64
         this.connection = xmpp.connection;
66
         this.connection = xmpp.connection;
65
 
67
 
66
         // The JID to which conference-iq requests are sent over XMPP.
68
         // The JID to which conference-iq requests are sent over XMPP.
393
             if (conferenceRequest.vnode && !this.options.iAmRecorder && !this.options.iAmSipGateway) {
395
             if (conferenceRequest.vnode && !this.options.iAmRecorder && !this.options.iAmSipGateway) {
394
                 logger.warn(`Redirected to: ${conferenceRequest.vnode} with focusJid ${conferenceRequest.focusJid} }`);
396
                 logger.warn(`Redirected to: ${conferenceRequest.vnode} with focusJid ${conferenceRequest.focusJid} }`);
395
 
397
 
396
-                this.eventEmitter.emit(XMPPEvents.REDIRECTED, conferenceRequest.vnode, conferenceRequest.focusJid);
398
+                this.xmpp.eventEmitter.emit(CONNECTION_REDIRECTED, conferenceRequest.vnode, conferenceRequest.focusJid);
397
 
399
 
398
                 return;
400
                 return;
399
             }
401
             }

+ 15
- 1
modules/xmpp/strophe.emuc.js 查看文件

2
 import $ from 'jquery';
2
 import $ from 'jquery';
3
 import { Strophe } from 'strophe.js';
3
 import { Strophe } from 'strophe.js';
4
 
4
 
5
+import { CONNECTION_REDIRECTED } from '../../JitsiConnectionEvents';
5
 import { XMPPEvents } from '../../service/xmpp/XMPPEvents';
6
 import { XMPPEvents } from '../../service/xmpp/XMPPEvents';
6
 
7
 
7
 import ChatRoom from './ChatRoom';
8
 import ChatRoom from './ChatRoom';
216
         const from = iq.getAttribute('from');
217
         const from = iq.getAttribute('from');
217
         const room = this.rooms[Strophe.getBareJidFromJid(from)];
218
         const room = this.rooms[Strophe.getBareJidFromJid(from)];
218
 
219
 
219
-        room?.onVisitorIQ(iq);
220
+        if (!room) {
221
+            return true;
222
+        }
223
+
224
+        const visitors = $(iq).find('>visitors[xmlns="jitsi:visitors"]');
225
+        const response = $(iq).find('promotion-response');
226
+
227
+        if (visitors.length && response.length
228
+            && String(response.attr('allow')).toLowerCase() === 'true') {
229
+            logger.warn('Redirected back to main room.');
230
+
231
+            this.xmpp.eventEmitter.emit(
232
+                CONNECTION_REDIRECTED, undefined, visitors.attr('focusjid'), response.attr('username'));
233
+        }
220
 
234
 
221
         return true;
235
         return true;
222
     }
236
     }

+ 0
- 5
service/xmpp/XMPPEvents.ts 查看文件

209
      */
209
      */
210
     RECORDER_STATE_CHANGED = 'xmpp.recorderStateChanged',
210
     RECORDER_STATE_CHANGED = 'xmpp.recorderStateChanged',
211
 
211
 
212
-    /**
213
-     * The conference was redirected to a visitor node.
214
-     */
215
-    REDIRECTED = 'xmpp.redirected',
216
-
217
     // Designates an event indicating that we received statistics from a
212
     // Designates an event indicating that we received statistics from a
218
     // participant in the MUC.
213
     // participant in the MUC.
219
     REMOTE_STATS = 'xmpp.remote_stats',
214
     REMOTE_STATS = 'xmpp.remote_stats',

Loading…
取消
儲存