|
@@ -15,6 +15,53 @@ import {
|
15
|
15
|
SET_LOCATION_URL
|
16
|
16
|
} from './actionTypes';
|
17
|
17
|
|
|
18
|
+/**
|
|
19
|
+ * The error structure passed to the {@link connectionFailed} action.
|
|
20
|
+ *
|
|
21
|
+ * Note there was an intention to make the error resemble an Error instance (to
|
|
22
|
+ * the extent that jitsi-meet needs it).
|
|
23
|
+ */
|
|
24
|
+export type ConnectionFailedError = {
|
|
25
|
+
|
|
26
|
+ /**
|
|
27
|
+ * The invalid credentials that were used to authenticate and the
|
|
28
|
+ * authentication failed.
|
|
29
|
+ */
|
|
30
|
+ credentials?: {
|
|
31
|
+
|
|
32
|
+ /**
|
|
33
|
+ * The XMPP user's ID.
|
|
34
|
+ */
|
|
35
|
+ jid: string,
|
|
36
|
+
|
|
37
|
+ /**
|
|
38
|
+ * The XMPP user's password.
|
|
39
|
+ */
|
|
40
|
+ password: string
|
|
41
|
+ },
|
|
42
|
+
|
|
43
|
+ /**
|
|
44
|
+ * The details about the connection failed event.
|
|
45
|
+ */
|
|
46
|
+ details?: string,
|
|
47
|
+
|
|
48
|
+ /**
|
|
49
|
+ * Error message.
|
|
50
|
+ */
|
|
51
|
+ message?: string,
|
|
52
|
+
|
|
53
|
+ /**
|
|
54
|
+ * One of {@link JitsiConnectionError} constants (defined in
|
|
55
|
+ * lib-jitsi-meet).
|
|
56
|
+ */
|
|
57
|
+ name: string,
|
|
58
|
+
|
|
59
|
+ /**
|
|
60
|
+ * Indicates whether this event is recoverable or not.
|
|
61
|
+ */
|
|
62
|
+ recoverable?: boolean
|
|
63
|
+}
|
|
64
|
+
|
18
|
65
|
/**
|
19
|
66
|
* Opens new connection.
|
20
|
67
|
*
|
|
@@ -89,10 +136,18 @@ export function connect(id: ?string, password: ?string) {
|
89
|
136
|
* @private
|
90
|
137
|
* @returns {void}
|
91
|
138
|
*/
|
92
|
|
- function _onConnectionFailed(err, msg, credentials) {
|
|
139
|
+ function _onConnectionFailed(
|
|
140
|
+ err: string, msg: string, credentials: Object) {
|
93
|
141
|
unsubscribe();
|
94
|
142
|
console.error('CONNECTION FAILED:', err, msg);
|
95
|
|
- dispatch(connectionFailed(connection, err, msg, credentials));
|
|
143
|
+ dispatch(
|
|
144
|
+ connectionFailed(
|
|
145
|
+ connection, {
|
|
146
|
+ credentials,
|
|
147
|
+ name: err,
|
|
148
|
+ message: msg
|
|
149
|
+ }
|
|
150
|
+ ));
|
96
|
151
|
}
|
97
|
152
|
|
98
|
153
|
/**
|
|
@@ -167,54 +222,34 @@ export function connectionEstablished(connection: Object) {
|
167
|
222
|
};
|
168
|
223
|
}
|
169
|
224
|
|
170
|
|
-/* eslint-disable max-params */
|
171
|
|
-
|
172
|
225
|
/**
|
173
|
226
|
* Create an action for when the signaling connection could not be created.
|
174
|
227
|
*
|
175
|
228
|
* @param {JitsiConnection} connection - The JitsiConnection which failed.
|
176
|
|
- * @param {string} error - Error.
|
177
|
|
- * @param {string} [message] - Error message.
|
178
|
|
- * @param {Object} [credentials] - The invalid credentials that failed
|
179
|
|
- * the authentication.
|
180
|
|
- * @param {Object} [details] - The details about the connection failed event.
|
181
|
|
- * @param {boolean} [recoverable] - Indicates whether this event is recoverable
|
182
|
|
- * or not.
|
|
229
|
+ * @param {ConnectionFailedError} error - Error.
|
183
|
230
|
* @public
|
184
|
231
|
* @returns {{
|
185
|
232
|
* type: CONNECTION_FAILED,
|
186
|
233
|
* connection: JitsiConnection,
|
187
|
|
- * error: Object
|
|
234
|
+ * error: ConnectionFailedError
|
188
|
235
|
* }}
|
189
|
236
|
*/
|
190
|
237
|
export function connectionFailed(
|
191
|
238
|
connection: Object,
|
192
|
|
- error: string,
|
193
|
|
- message: ?string,
|
194
|
|
- credentials: ?Object,
|
195
|
|
- details: ?Object,
|
196
|
|
- recoverable: ?boolean) {
|
|
239
|
+ error: ConnectionFailedError) {
|
|
240
|
+ const { credentials } = error;
|
|
241
|
+
|
|
242
|
+ if (credentials && !Object.keys(credentials).length) {
|
|
243
|
+ error.credentials = undefined;
|
|
244
|
+ }
|
|
245
|
+
|
197
|
246
|
return {
|
198
|
247
|
type: CONNECTION_FAILED,
|
199
|
248
|
connection,
|
200
|
|
-
|
201
|
|
- // Make the error resemble an Error instance (to the extent that
|
202
|
|
- // jitsi-meet needs it).
|
203
|
|
- error: {
|
204
|
|
- credentials:
|
205
|
|
- credentials && Object.keys(credentials).length
|
206
|
|
- ? credentials
|
207
|
|
- : undefined,
|
208
|
|
- message,
|
209
|
|
- name: error,
|
210
|
|
- details,
|
211
|
|
- recoverable
|
212
|
|
- }
|
|
249
|
+ error
|
213
|
250
|
};
|
214
|
251
|
}
|
215
|
252
|
|
216
|
|
-/* eslint-enable max-params */
|
217
|
|
-
|
218
|
253
|
/**
|
219
|
254
|
* Constructs options to be passed to the constructor of {@code JitsiConnection}
|
220
|
255
|
* based on the redux state.
|