transfer project in github
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
const Order = require('../models/Order')
|
||||
module.exports.initAdmin = async () => {
|
||||
try {
|
||||
global.adminIo = io.of('/admin')
|
||||
|
||||
// admins middlewares1
|
||||
// admin.use(isAdmin)
|
||||
|
||||
// attach events
|
||||
adminIo.on('connection', socket => {
|
||||
console.log('admin connected')
|
||||
/// /////////////////////////////////////////////////////// handle connection error
|
||||
socket.on('connect_error', err => {
|
||||
console.log(err.message)
|
||||
})
|
||||
})
|
||||
}catch (e) {
|
||||
console.log(e.message)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.sendNotifyOrder = async (branchId) => {
|
||||
try {
|
||||
adminIo.emit('order' , {branchId})
|
||||
}catch (e) {
|
||||
console.log(e.message)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
const {initAdmin} = require('./adminNotify')
|
||||
|
||||
function init(server) {
|
||||
// const http = require('http');
|
||||
// const server = http.createServer(app);
|
||||
const { Server } = require("socket.io");
|
||||
global.io
|
||||
|
||||
io = new Server(server);
|
||||
|
||||
initAdmin()
|
||||
}
|
||||
|
||||
|
||||
module.exports = init
|
||||
Reference in New Issue
Block a user