budibase/packages/server/src/websocket.ts

21 lines
369 B
TypeScript
Raw Normal View History

2022-08-22 19:24:34 +02:00
import SocketIO from "socket.io"
export class Websocket {
socketIO: any
constructor(server: any, path: string) {
// @ts-ignore
this.socketIO = SocketIO(server, {
path,
cors: {
origin: "*",
},
})
}
// Emit an event to all sockets
emit(event: string, payload: any) {
this.socketIO.sockets.emit(event, payload)
}
}