diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..34a9dbd --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +build +.lock* diff --git a/helloworld/test.js b/helloworld/test.js new file mode 100644 index 0000000..4040caa --- /dev/null +++ b/helloworld/test.js @@ -0,0 +1,3 @@ +var helloWorld = require('./build/Release/helloworld'); +var world = new helloWorld.HelloWorld(); +console.log(world.hello()); diff --git a/helloworld_eio/helloworld_eio.cc b/helloworld_eio/helloworld_eio.cc index 3943439..48a38c7 100644 --- a/helloworld_eio/helloworld_eio.cc +++ b/helloworld_eio/helloworld_eio.cc @@ -87,15 +87,13 @@ class HelloWorldEio: ObjectWrap } - static int EIO_Hello(eio_req *req) + static void EIO_Hello(eio_req *req) { hello_baton_t *baton = static_cast(req->data); sleep(baton->sleep_for); baton->hw->m_count += baton->increment_by; - - return 0; } static int EIO_AfterHello(eio_req *req) diff --git a/helloworld_eio/test.js b/helloworld_eio/test.js new file mode 100644 index 0000000..48648d1 --- /dev/null +++ b/helloworld_eio/test.js @@ -0,0 +1,8 @@ +var helloeio = require('./build/Release/helloworld_eio'); +var hi = new helloeio.HelloWorldEio(); +hi.hello(function(data){ + console.log(data); +}); +//Outputting something here to show that the callback is non-blocking and this +//output will be displayed before the Hello World message. +console.log('Outputted after the async call to hello world.');