set protocol when connecting

This commit is contained in:
2020-09-21 03:07:00 +02:00
parent 6776067dcb
commit a51ccb9cdc
+3 -3
View File
@@ -5,13 +5,13 @@ import * as socketio from 'socket.io-client'
export class PromiseIOClient {
static connect = (port: number, host = "localhost"): Promise<I.Socket> => new Promise((res, rej) => {
static connect = (port: number, host = "localhost", protocol : 'http:' | 'https:' = "http:"): Promise<I.Socket> => new Promise((res, rej) => {
try {
const socket = socketio(`http://${host}:${port}`, {
const socket = socketio(`${protocol}//${host}:${port}`, {
reconnectionAttempts: 2,
reconnectionDelay: 200,
timeout: 450,
reconnection: false
reconnection: false,
})
socket.on('connect_error', e => {
sock.emit('error', e)