diff --git a/packages/client/src/websocket.js b/packages/client/src/websocket.js index 8c151e6ab9..1a4ee49a92 100644 --- a/packages/client/src/websocket.js +++ b/packages/client/src/websocket.js @@ -14,7 +14,7 @@ export const initWebsocket = () => { const tls = location.protocol === "https:" const proto = tls ? "wss:" : "ws:" const host = location.hostname - const port = location.port || (tls ? 433 : 80) + const port = location.port || (tls ? 443 : 80) console.log(`${proto}//${host}:${port}`) const socket = io(`${proto}//${host}:${port}`, { path: "/socket/client", diff --git a/packages/server/src/websocket.ts b/packages/server/src/websocket.ts index db61c34358..52942ab795 100644 --- a/packages/server/src/websocket.ts +++ b/packages/server/src/websocket.ts @@ -1,20 +1,17 @@ -import SocketIO from "socket.io" +import { Server } from "socket.io" +import http from "http" export class Websocket { - socketIO: any + socketServer: Server - constructor(server: any, path: string) { - // @ts-ignore - this.socketIO = SocketIO(server, { + constructor(server: http.Server, path: string) { + this.socketServer = new Server(server, { path, - cors: { - origin: "*", - }, }) } // Emit an event to all sockets emit(event: string, payload: any) { - this.socketIO.sockets.emit(event, payload) + this.socketServer.sockets.emit(event, payload) } }