21 lines
411 B
TypeScript
21 lines
411 B
TypeScript
import { Server } from 'socket.io'
|
|
import { createServer } from 'http'
|
|
|
|
let io = null
|
|
|
|
export const setIo = (app) => {
|
|
const server = createServer(app)
|
|
io = new Server(server, {
|
|
cors: {
|
|
origin: "*",
|
|
methods: ["GET", "POST"],
|
|
credentials: false
|
|
},
|
|
transports: ['websocket', 'polling']
|
|
})
|
|
|
|
return server
|
|
}
|
|
|
|
export const getIo = () => io
|