-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.js
executable file
·29 lines (27 loc) · 1.41 KB
/
publish.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
var config = require('./config')
var redisClient = require("redis").createClient(config.redis.port, config.redis.host);
if (config.redis.auth) {
redisClient.auth(config.redis.auth);
}
var status = [false, false, false, false, false, false, false];
redisClient.publish(config.redis.channel, JSON.stringify({"toUserId": 101, "message": new Date().getTime()}),
function (){ status[0]=true; exit(); });
redisClient.publish(config.redis.channel, JSON.stringify({"toUserId": 102, "message": new Date().getTime()}),
function (){ status[1]=true; exit(); });
redisClient.publish(config.redis.channel, JSON.stringify({"toUserId": 103, "message": new Date().getTime()}),
function (){ status[2]=true; exit(); });
redisClient.publish(config.redis.channel, JSON.stringify({"toUserId": 104, "message": new Date().getTime()}),
function (){ status[3]=true; exit(); });
redisClient.publish(config.redis.channel, JSON.stringify({"toUserId": 105, "message": new Date().getTime()}),
function (){ status[4]=true; exit(); });
redisClient.publish(config.redis.channel, JSON.stringify({"toUserId": 106, "message": new Date().getTime()}),
function (){ status[5]=true; exit(); });
redisClient.publish(config.redis.channel, JSON.stringify({"toUserId": 107, "message": new Date().getTime()}),
function (){ status[6]=true; exit(); });
function exit() {
var exit = false
status.forEach(function(value) { exit = value })
if (exit) {
process.exit(1);
}
}