1 var redis = require("redis"),
2 client1 = redis.createClient(), msg_count = 0,
3 client2 = redis.createClient();
5 redis.debug_mode = false;
7 // Most clients probably don't do much on "subscribe". This example uses it to coordinate things within one program.
8 client1.on("subscribe", function (channel, count) {
9 console.log("client1 subscribed to " + channel + ", " + count + " total subscriptions");
11 client2.publish("a nice channel", "I am sending a message.");
12 client2.publish("another one", "I am sending a second message.");
13 client2.publish("a nice channel", "I am sending my last message.");
17 client1.on("unsubscribe", function (channel, count) {
18 console.log("client1 unsubscribed from " + channel + ", " + count + " total subscriptions");
25 client1.on("message", function (channel, message) {
26 console.log("client1 channel " + channel + ": " + message);
28 if (msg_count === 3) {
29 client1.unsubscribe();
33 client1.on("ready", function () {
34 // if you need auth, do it here
35 client1.incr("did a thing");
36 client1.subscribe("a nice channel", "another one");
39 client2.on("ready", function () {
40 // if you need auth, do it here