diff options
author | Fraser Adams <fraser.adams@blueyonder.co.uk> | 2014-06-13 17:49:40 +0100 |
---|---|---|
committer | Fraser Adams <fraser.adams@blueyonder.co.uk> | 2014-06-13 17:49:40 +0100 |
commit | 35955f370222c84c97d1b3ee33de7ca1e4214b32 (patch) | |
tree | 3ba7a2fb8ce1d44665844c977d956b548eb49b75 | |
parent | 257cbc006f152d233ceaa9943228f8fb179f2348 (diff) |
Add some more documentation to emscripten.h to explain that the JavaScript error callback takes an array containing the file descriptor, error code and error message.
-rw-r--r-- | system/include/emscripten/emscripten.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/system/include/emscripten/emscripten.h b/system/include/emscripten/emscripten.h index 994a75a7..d669938d 100644 --- a/system/include/emscripten/emscripten.h +++ b/system/include/emscripten/emscripten.h @@ -176,11 +176,13 @@ extern void emscripten_cancel_main_loop(void); * * The userData pointer allows arbitrary data specified during Event * registration to be passed to the callback, this is particularly - * useful for passing "this" pointers around in Object Orienter code. + * useful for passing "this" pointers around in Object Oriented code. * * In addition to being able to register network callbacks from C * it is also possible for native JavaScript code to directly use the - * underlying mechanism used to implement the callback registration: + * underlying mechanism used to implement the callback registration. + * For example, the following are the simple logging callbacks that + * are registered by default when SOCKET_DEBUG is enabled * Module['websocket']['on']('error', function(error) {console.log('Socket error ' + error);}); * Module['websocket']['on']('open', function(fd) {console.log('Socket open fd = ' + fd);}); * Module['websocket']['on']('listen', function(fd) {console.log('Socket listen fd = ' + fd);}); @@ -188,6 +190,11 @@ extern void emscripten_cancel_main_loop(void); * Module['websocket']['on']('message', function(fd) {console.log('Socket message fd = ' + fd);}); * Module['websocket']['on']('close', function(fd) {console.log('Socket close fd = ' + fd);}); * + * Most of the JavaScript callback functions above get passed the + * file descriptor of the socket that triggered the callback, the + * on error callback however gets passed an *array* that contains + * the file descriptor, the error code and an error message. + * * Note that the underlying JavaScript implementation doesn't pass * userData, this is actually mostly of use to C/C++ code and the * emscripten_set_socket_*_callback calls actually create a closure |