Browse Source

add useWSS default value (#75)

* Set the default value of useWSS to true if running from browser and protocol is https

* Set useWSS to boolean in TelegramClientParams

* Check if window is undefined to decide on default useWSS value
Roj Serbest 4 years ago
parent
commit
adaca46bb5
1 changed files with 2 additions and 2 deletions
  1. 2 2
      gramjs/client/telegramBaseClient.ts

+ 2 - 2
gramjs/client/telegramBaseClient.ts

@@ -33,7 +33,7 @@ export interface TelegramClientParams {
     langCode?: 'en',
     systemLangCode?: 'en',
     baseLogger?: string | any,
-    useWSS?: false,
+    useWSS?: boolean,
 }
 
 export class TelegramBaseClient {
@@ -81,7 +81,7 @@ export class TelegramBaseClient {
         langCode = 'en',
         systemLangCode = 'en',
         baseLogger = 'gramjs',
-        useWSS = false,
+        useWSS = typeof window !== 'undefined' ? window.location.protocol == 'https:' : false,
     }: TelegramClientParams) {
         if (!apiId || !apiHash) {
             throw new Error("Your API ID or Hash cannot be empty or undefined");