From d557a6505dde4b24e3e8a598eb0cdb0957478808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Wed, 23 May 2018 13:43:40 +0200 Subject: [PATCH] [RN] Fix handling XMPP connection failures After the connection is established, it can either be properly disconnected or fail. We need to make sure to be listening for events for either. --- .../features/base/connection/actions.native.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/react/features/base/connection/actions.native.js b/react/features/base/connection/actions.native.js index e19f4e474..0c5216438 100644 --- a/react/features/base/connection/actions.native.js +++ b/react/features/base/connection/actions.native.js @@ -108,10 +108,7 @@ export function connect(id: ?string, password: ?string) { * @returns {void} */ function _onConnectionDisconnected(message: string) { - connection.removeEventListener( - JitsiConnectionEvents.CONNECTION_DISCONNECTED, - _onConnectionDisconnected); - + unsubscribe(); dispatch(_connectionDisconnected(connection, message)); } @@ -122,7 +119,9 @@ export function connect(id: ?string, password: ?string) { * @returns {void} */ function _onConnectionEstablished() { - unsubscribe(); + connection.removeEventListener( + JitsiConnectionEvents.CONNECTION_ESTABLISHED, + _onConnectionEstablished); dispatch(connectionEstablished(connection)); } @@ -141,7 +140,6 @@ export function connect(id: ?string, password: ?string) { function _onConnectionFailed( err: string, msg: string, credentials: Object) { unsubscribe(); - console.error('CONNECTION FAILED:', err, msg); dispatch( connectionFailed( connection, { @@ -153,15 +151,15 @@ export function connect(id: ?string, password: ?string) { } /** - * Unsubscribes connection instance from {@code CONNECTION_ESTABLISHED} - * and {@code CONNECTION_FAILED} events. + * Unsubscribe the connection instance from + * {@code CONNECTION_DISCONNECTED} and {@code CONNECTION_FAILED} events. * * @returns {void} */ function unsubscribe() { connection.removeEventListener( - JitsiConnectionEvents.CONNECTION_ESTABLISHED, - _onConnectionEstablished); + JitsiConnectionEvents.CONNECTION_DISCONNECTED, + _onConnectionDisconnected); connection.removeEventListener( JitsiConnectionEvents.CONNECTION_FAILED, _onConnectionFailed);