12345678910111213141516171819202122232425262728293031323334 |
- let config = require('./config/appconfig.js')
- export default class Pusher {
- constructor () { // eslint-disable-line
- }
- /**
- * 处理采集服务器过来的 PUSH 消息
- * 广播给所有在线的监控客户端
- *
- * @method doPUSH
- *
- * @param {[type]} socket [description]
- * @param {[type]} message [description]
- *
- * @return {[type]} [description]
- */
- static push (socket, message, username) {
- let userInfo = socket.handshake.session.user
- if (userInfo.name === config.COLLECTOR) {
- if (socket.auth) {
- socket.to(config.MONITOR).emit('PUSH', message)
- console.log(userInfo.name+'发送了')
- if (message.cmd === 'up_mine') {
- socket.to(config.STANDBY).emit('PUSH', message)
- }
- } else {
- console.log('用户尚未登录,无法 PUSH 消息!')
- }
- } else {
- console.warn(`用户 ${userInfo.name} 没有 PUSH 权限!`)
- }
- }
- }
|