浏览代码

fix(transport): remove legacy code

It has been around bor > 2.5 years already.
j8
Saúl Ibarra Corretgé 5 年前
父节点
当前提交
00b57c7983
共有 2 个文件被更改,包括 2 次插入104 次删除
  1. 1
    98
      modules/transport/PostMessageTransportBackend.js
  2. 1
    6
      modules/transport/index.js

+ 1
- 98
modules/transport/PostMessageTransportBackend.js 查看文件

9
     window: window.opener || window.parent
9
     window: window.opener || window.parent
10
 };
10
 };
11
 
11
 
12
-/**
13
- * The list of methods of incoming postis messages that we have to support for
14
- * backward compatibility for the users that are directly sending messages to
15
- * Jitsi Meet (without using external_api.js)
16
- *
17
- * @type {string[]}
18
- */
19
-const LEGACY_INCOMING_METHODS = [
20
-    'avatar-url',
21
-    'display-name',
22
-    'email',
23
-    'toggle-audio',
24
-    'toggle-chat',
25
-    'toggle-film-strip',
26
-    'toggle-share-screen',
27
-    'toggle-video',
28
-    'video-hangup'
29
-];
30
-
31
-/**
32
- * The list of methods of outgoing postis messages that we have to support for
33
- * backward compatibility for the users that are directly listening to the
34
- * postis messages send by Jitsi Meet(without using external_api.js).
35
- *
36
- * @type {string[]}
37
- */
38
-const LEGACY_OUTGOING_METHODS = [
39
-    'display-name-change',
40
-    'incoming-message',
41
-    'outgoing-message',
42
-    'participant-joined',
43
-    'participant-left',
44
-    'video-conference-joined',
45
-    'video-conference-left',
46
-    'video-ready-to-close'
47
-];
48
-
49
 /**
12
 /**
50
  * The postis method used for all messages.
13
  * The postis method used for all messages.
51
  *
14
  *
63
      * @param {Object} options - Optional parameters for configuration of the
26
      * @param {Object} options - Optional parameters for configuration of the
64
      * transport.
27
      * transport.
65
      */
28
      */
66
-    constructor({ enableLegacyFormat, postisOptions } = {}) {
29
+    constructor({ postisOptions } = {}) {
67
         // eslint-disable-next-line new-cap
30
         // eslint-disable-next-line new-cap
68
         this.postis = Postis({
31
         this.postis = Postis({
69
             ...DEFAULT_POSTIS_OPTIONS,
32
             ...DEFAULT_POSTIS_OPTIONS,
70
             ...postisOptions
33
             ...postisOptions
71
         });
34
         });
72
 
35
 
73
-        /**
74
-         * If true PostMessageTransportBackend will process and send messages
75
-         * using the legacy format and in the same time the current format.
76
-         * Otherwise all messages (outgoing and incoming) that are using the
77
-         * legacy format will be ignored.
78
-         *
79
-         * @type {boolean}
80
-         */
81
-        this._enableLegacyFormat = enableLegacyFormat;
82
-
83
-        if (this._enableLegacyFormat) {
84
-            // backward compatibility
85
-            LEGACY_INCOMING_METHODS.forEach(method =>
86
-                this.postis.listen(
87
-                    method,
88
-                    params =>
89
-                        this._legacyMessageReceivedCallback(method, params)
90
-                )
91
-            );
92
-        }
93
-
94
         this._receiveCallback = () => {
36
         this._receiveCallback = () => {
95
             // Do nothing until a callback is set by the consumer of
37
             // Do nothing until a callback is set by the consumer of
96
             // PostMessageTransportBackend via setReceiveCallback.
38
             // PostMessageTransportBackend via setReceiveCallback.
101
             message => this._receiveCallback(message));
43
             message => this._receiveCallback(message));
102
     }
44
     }
103
 
45
 
104
-    /**
105
-     * Handles incoming legacy postis messages.
106
-     *
107
-     * @param {string} method - The method property from the postis message.
108
-     * @param {Any} params - The params property from the postis message.
109
-     * @returns {void}
110
-     */
111
-    _legacyMessageReceivedCallback(method, params = {}) {
112
-        this._receiveCallback({
113
-            data: {
114
-                name: method,
115
-                data: params
116
-            }
117
-        });
118
-    }
119
-
120
-    /**
121
-     * Sends the passed message via postis using the old format.
122
-     *
123
-     * @param {Object} legacyMessage - The message to be sent.
124
-     * @returns {void}
125
-     */
126
-    _sendLegacyMessage({ name, ...data }) {
127
-        if (name && LEGACY_OUTGOING_METHODS.indexOf(name) !== -1) {
128
-            this.postis.send({
129
-                method: name,
130
-                params: data
131
-            });
132
-        }
133
-    }
134
-
135
     /**
46
     /**
136
      * Disposes the allocated resources.
47
      * Disposes the allocated resources.
137
      *
48
      *
152
             method: POSTIS_METHOD_NAME,
63
             method: POSTIS_METHOD_NAME,
153
             params: message
64
             params: message
154
         });
65
         });
155
-
156
-        if (this._enableLegacyFormat) {
157
-            // For the legacy use case we don't need any new fields defined in
158
-            // Transport class. That's why we are passing only the original
159
-            // object passed by the consumer of the Transport class which is
160
-            // message.data.
161
-            this._sendLegacyMessage(message.data || {});
162
-        }
163
     }
66
     }
164
 
67
 
165
     /**
68
     /**

+ 1
- 6
modules/transport/index.js 查看文件

36
  */
36
  */
37
 export function getJitsiMeetTransport() {
37
 export function getJitsiMeetTransport() {
38
     if (!transport) {
38
     if (!transport) {
39
-        transport = new Transport({
40
-            backend: new PostMessageTransportBackend({
41
-                enableLegacyFormat: true,
42
-                postisOptions
43
-            })
44
-        });
39
+        transport = new Transport({ backend: new PostMessageTransportBackend({ postisOptions }) });
45
     }
40
     }
46
 
41
 
47
     return transport;
42
     return transport;

正在加载...
取消
保存