mirror of
https://github.com/chaos-zhu/easynode.git
synced 2026-05-31 23:19:27 +08:00
21 lines
405 B
JavaScript
21 lines
405 B
JavaScript
const { Server } = require('socket.io')
|
|
const { verifyWsAuthSync } = require('./verify-auth')
|
|
|
|
const createSecureWs = (httpServer, path, otherConfig = {}) => {
|
|
const serverIo = new Server(httpServer, {
|
|
path,
|
|
cors: {
|
|
origin: true,
|
|
credentials: true
|
|
},
|
|
...otherConfig
|
|
})
|
|
// 鉴权
|
|
serverIo.use(verifyWsAuthSync)
|
|
|
|
return serverIo
|
|
}
|
|
|
|
module.exports = {
|
|
createSecureWs
|
|
} |