From 9d514690f030564b01cd31715d802a2ec3c91f54 Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Silva Date: Thu, 19 May 2022 13:43:49 -0300 Subject: [PATCH] Chore: Fix websocket connection to sdk (#4182) --- app/lib/services/connect.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/lib/services/connect.ts b/app/lib/services/connect.ts index 229be4204..caca9caaa 100644 --- a/app/lib/services/connect.ts +++ b/app/lib/services/connect.ts @@ -1,5 +1,5 @@ import RNFetchBlob from 'rn-fetch-blob'; -import { settings as RocketChatSettings } from '@rocket.chat/sdk'; +import { settings as RocketChatSettings, Rocketchat as RocketchatClient } from '@rocket.chat/sdk'; import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord'; import { InteractionManager } from 'react-native'; import { Q } from '@nozbe/watermelondb'; @@ -23,6 +23,7 @@ import { updateSettings } from '../../actions/settings'; import { defaultSettings, MIN_ROCKETCHAT_VERSION } from '../constants'; import { compareServerVersion } from '../methods/helpers/compareServerVersion'; import { onRolesChanged } from '../methods/getRoles'; +import { isSsl } from '../../utils/url'; import { getSettings, IActiveUsers, unsubscribeRooms, _activeUsers, _setUser, _setUserTimer } from '../methods'; interface IServices { @@ -425,10 +426,10 @@ async function getServerInfo(server: string) { } async function getWebsocketInfo({ server }: { server: string }) { - sdk.initialize(server); + const websocketSdk = new RocketchatClient({ host: server, protocol: 'ddp', useSsl: isSsl(server) }); try { - await sdk.current.connect(); + await websocketSdk.connect(); } catch (err: any) { if (err.message && err.message.includes('400')) { return { @@ -438,7 +439,7 @@ async function getWebsocketInfo({ server }: { server: string }) { } } - sdk.disconnect(); + websocketSdk.disconnect(); return { success: true