diff --git a/src/binding.cc b/src/binding.cc index 68e130a7..071dbe35 100644 --- a/src/binding.cc +++ b/src/binding.cc @@ -242,6 +242,8 @@ protected: assert(PQisnonblocking(connection_)); + PQsetNoticeReceiver(connection_, NoticeReceiver, NULL); + TRACE("Setting watchers to socket"); ev_io_set(&read_watcher_, fd, EV_READ); ev_io_set(&write_watcher_, fd, EV_WRITE); @@ -253,6 +255,11 @@ protected: return true; } + static void NoticeReceiver(void *arg, const PGresult *res) + { + printf("*****NOTICE*********%s","\n"); + } + void HandleNotice(void *arg, const PGresult *res) { } diff --git a/test/unit/client/notification-tests.js b/test/unit/client/notification-tests.js new file mode 100644 index 00000000..d9e725b4 --- /dev/null +++ b/test/unit/client/notification-tests.js @@ -0,0 +1,9 @@ +var helper = require(__dirname + "/test-helper"); +test('passes connection notification', function() { + var client = new Client(); + assert.emits(client, 'notify', function(msg) { + assert.equal(msg, "HAY!!"); + }) + client.connection.emit('notify', "HAY!!"); +}) +