瀏覽代碼

set protocol when connecting

master
peter 4 年之前
父節點
當前提交
a51ccb9cdc
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3
    3
      src/PromiseIO/Client.ts

+ 3
- 3
src/PromiseIO/Client.ts 查看文件

@@ -5,13 +5,13 @@ import * as socketio from 'socket.io-client'
5 5
 
6 6
 export class PromiseIOClient {
7 7
     
8
-    static connect = (port: number, host = "localhost"): Promise<I.Socket> => new Promise((res, rej) => {
8
+    static connect = (port: number, host = "localhost", protocol : 'http:' | 'https:' = "http:"): Promise<I.Socket> => new Promise((res, rej) => {
9 9
         try {
10
-            const socket = socketio(`http://${host}:${port}`, {
10
+            const socket = socketio(`${protocol}//${host}:${port}`, {
11 11
                 reconnectionAttempts: 2,
12 12
                 reconnectionDelay: 200,
13 13
                 timeout: 450,
14
-                reconnection: false
14
+                reconnection: false,
15 15
             })
16 16
             socket.on('connect_error', e => {
17 17
                 sock.emit('error', e)

Loading…
取消
儲存