update 'notification' example to end listening client after message received

brianc 2011-04-12 14:16:01 -07:00
parent eb6e9273aa
commit ffd64b02ba

@ -310,13 +310,13 @@ Used for "LISTEN/NOTIFY" interactions. You can do some fun pub-sub style stuff
client2.connect();
client1.on('notification', function(msg) {
console.log(msg.channel); //outputs 'boom'
client1.end();
});
client1.query("LISTEN boom");
//need to let the first query actually complete
//client1 will remain listening to channel 'boom' until it's 'end' is called
setTimeout(function() {
client2.query("NOTIFY boom", function() {
client1.end();
client2.end();
});
}, 1000);