diff --git a/lib/.#client.js b/lib/.#client.js new file mode 120000 index 0000000..abbd853 --- /dev/null +++ b/lib/.#client.js @@ -0,0 +1 @@ +bmc@explodemy.com.14585:1298675411 \ No newline at end of file diff --git a/lib/client.js b/lib/client.js index 5ec9267..98e454b 100644 --- a/lib/client.js +++ b/lib/client.js @@ -23,9 +23,12 @@ var Client = function(config) { this.password = config.password || defaults.password; this.encoding = 'utf8'; var self = this; +<<<<<<< HEAD this.connection.on('notification', function(msg) { self.emit('notification', msg); }) +======= +>>>>>>> master }; sys.inherits(Client, EventEmitter); @@ -89,6 +92,11 @@ p.connect = function() { }); self.emit('connect'); + + con.on('notification', function(msg) { + self.emit('notification', msg); + }) + }); con.on('readyForQuery', function() { @@ -112,6 +120,11 @@ p.connect = function() { self.activeQuery = null; } }); + + con.on('notice', function(msg) { + self.emit('notice', msg); + }) + }; p._pulseQueryQueue = function() { diff --git a/test/integration/client/notice-tests.js b/test/integration/client/notice-tests.js new file mode 100644 index 0000000..b3c5f43 --- /dev/null +++ b/test/integration/client/notice-tests.js @@ -0,0 +1,26 @@ +var helper = require(__dirname + '/test-helper'); +test('emits notice message', function() { + var client = helper.client(); + client.query('create temp table boom(id serial, size integer)'); + assert.emits(client, 'notice', function(notice) { + assert.ok(notice != null); + client.end(); + }); +}) + +test('emits notify message', function() { + var client = helper.client(); + client.query('LISTEN boom', assert.calls(function() { + var otherClient = helper.client(); + otherClient.query('LISTEN boom', assert.calls(function() { + client.query('NOTIFY boom'); + assert.emits(client, 'notification', function(msg) { + client.end() + }); + assert.emits(otherClient, 'notification', function(msg) { + otherClient.end(); + }); + })); + })); +}) +