Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / redis / examples / psubscribe.js
1 var redis = require("redis"),
2     client1 = redis.createClient(),
3     client2 = redis.createClient(),
4     client3 = redis.createClient(),
5     client4 = redis.createClient(),
6     msg_count = 0;
7
8 redis.debug_mode = false;
9
10 client1.on("psubscribe", function (pattern, count) {
11     console.log("client1 psubscribed to " + pattern + ", " + count + " total subscriptions");
12     client2.publish("channeltwo", "Me!");
13     client3.publish("channelthree", "Me too!");
14     client4.publish("channelfour", "And me too!");
15 });
16
17 client1.on("punsubscribe", function (pattern, count) {
18     console.log("client1 punsubscribed from " + pattern + ", " + count + " total subscriptions");
19     client4.end();
20     client3.end();
21     client2.end();
22     client1.end();
23 });
24
25 client1.on("pmessage", function (pattern, channel, message) {
26     console.log("("+  pattern +")" + " client1 received message on " + channel + ": " + message);
27     msg_count += 1;
28     if (msg_count === 3) {
29         client1.punsubscribe();
30     }
31 });
32
33 client1.psubscribe("channel*");