-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
34 lines (30 loc) · 949 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require('./config');
require('./modules/api');
// require('bt-utils');
require('./library/bt');
require('./library/log4/build');
require('./library/redis/build');
require('./library/robot.js');
var listen = require('./modules/listen');
var mq = require('./modules/mq');
var room = require('./modules/room');
var INmessage = require('./modules/INmessage');
listen.wss.on('connection', function connection(ws) {
// bt.log('链接成功!');
// 将新用户加入队列
mq.add(global.userInfo,ws,()=>{
room.handle(global.userInfo.openid);
},listen.event.close);
// 接受消息
ws.on('message', function incoming(json) {
INmessage.handle(JSON.parse(json));
});
});
setInterval(()=>{
redis.set('mq_list',JSON.stringify(mq.client_list()));
redis.set('room_list',JSON.stringify(room.get_List()));
},3000);
process.on('uncaughtException', function (err) {
log.info(err);
log.info(err.stack);
});