1 var redis = require("redis"),
2 client1 = redis.createClient(),
3 client2 = redis.createClient(),
4 client3 = redis.createClient(),
5 client4 = redis.createClient(),
8 redis.debug_mode = false;
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!");
17 client1.on("punsubscribe", function (pattern, count) {
18 console.log("client1 punsubscribed from " + pattern + ", " + count + " total subscriptions");
25 client1.on("pmessage", function (pattern, channel, message) {
26 console.log("("+ pattern +")" + " client1 received message on " + channel + ": " + message);
28 if (msg_count === 3) {
29 client1.punsubscribe();
33 client1.psubscribe("channel*");