set protocol when connecting
This commit is contained in:
@@ -5,13 +5,13 @@ import * as socketio from 'socket.io-client'
|
|||||||
|
|
||||||
export class PromiseIOClient {
|
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 {
|
try {
|
||||||
const socket = socketio(`http://${host}:${port}`, {
|
const socket = socketio(`${protocol}//${host}:${port}`, {
|
||||||
reconnectionAttempts: 2,
|
reconnectionAttempts: 2,
|
||||||
reconnectionDelay: 200,
|
reconnectionDelay: 200,
|
||||||
timeout: 450,
|
timeout: 450,
|
||||||
reconnection: false
|
reconnection: false,
|
||||||
})
|
})
|
||||||
socket.on('connect_error', e => {
|
socket.on('connect_error', e => {
|
||||||
sock.emit('error', e)
|
sock.emit('error', e)
|
||||||
|
|||||||
Reference in New Issue
Block a user