From 16aa5ae9816d11021c555dfdfc89444b5beece3c Mon Sep 17 00:00:00 2001 From: brianc Date: Thu, 3 Mar 2011 22:55:06 -0600 Subject: [PATCH] working on bubbling up notifications --- src/binding.cc | 7 +++++++ test/unit/client/notification-tests.js | 9 +++++++++ 2 files changed, 16 insertions(+) create mode 100644 test/unit/client/notification-tests.js 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!!"); +}) +