24 lines
721 B
JavaScript
24 lines
721 B
JavaScript
const { isAdmin } = require('../middlewares/ws_authentication')
|
|
const adminEventsController = require('../controllers/admin_EventsController')
|
|
|
|
module.exports.adminNamespace = () => {
|
|
const io = global._io
|
|
const admin = io.of('/admin')
|
|
|
|
// admins middlewares
|
|
admin.use(isAdmin)
|
|
|
|
// attach events
|
|
admin.on('connection', socket => {
|
|
adminEventsController.getAllNotifs(socket)
|
|
|
|
/// /////////////////////////////////////////////////////// handle connection error
|
|
socket.on('connect_error', err => {
|
|
console.log(err.message)
|
|
})
|
|
|
|
/// ////////////////////////////////////////////////////// events
|
|
// socket.on('admin:getNotifs', () => adminEventsController.getAllNotifs(socket))
|
|
})
|
|
}
|