浏览代码

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 年之前
父节点
当前提交
adaca46bb5
共有 1 个文件被更改,包括 2 次插入2 次删除
  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");