diff options
author | Max Romanov <max.romanov@nginx.com> | 2019-08-20 16:32:05 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2019-08-20 16:32:05 +0300 |
commit | e291841b3379f8787a10ad4f91e4aeae2ae323a4 (patch) | |
tree | 49a2f4629e5b8d6cd48f7436d7eeba4c99905675 /src/nodejs/unit-http/unit.h | |
parent | e501c74ddceab86e48c031ca9b5e154f52dcdae0 (diff) | |
download | unit-e291841b3379f8787a10ad4f91e4aeae2ae323a4.tar.gz unit-e291841b3379f8787a10ad4f91e4aeae2ae323a4.tar.bz2 |
Node.js: introducing websocket support.
Diffstat (limited to 'src/nodejs/unit-http/unit.h')
-rw-r--r-- | src/nodejs/unit-http/unit.h | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/nodejs/unit-http/unit.h b/src/nodejs/unit-http/unit.h index e76d805a..f5eaf9fd 100644 --- a/src/nodejs/unit-http/unit.h +++ b/src/nodejs/unit-http/unit.h @@ -19,14 +19,28 @@ private: static napi_value create(napi_env env, napi_callback_info info); static void destroy(napi_env env, void *nativeObject, void *finalize_hint); + static void conn_destroy(napi_env env, void *nativeObject, void *finalize_hint); + static void sock_destroy(napi_env env, void *nativeObject, void *finalize_hint); + static void resp_destroy(napi_env env, void *nativeObject, void *finalize_hint); static napi_value create_server(napi_env env, napi_callback_info info); static napi_value listen(napi_env env, napi_callback_info info); static napi_value _read(napi_env env, napi_callback_info info); - static void request_handler(nxt_unit_request_info_t *req); + + static void request_handler_cb(nxt_unit_request_info_t *req); + void request_handler(nxt_unit_request_info_t *req); + + static void websocket_handler_cb(nxt_unit_websocket_frame_t *ws); + void websocket_handler(nxt_unit_websocket_frame_t *ws); + + static void close_handler_cb(nxt_unit_request_info_t *req); + void close_handler(nxt_unit_request_info_t *req); + static int add_port(nxt_unit_ctx_t *ctx, nxt_unit_port_t *port); static void remove_port(nxt_unit_ctx_t *ctx, nxt_unit_port_id_t *port_id); - static void quit(nxt_unit_ctx_t *ctx); + + static void quit_cb(nxt_unit_ctx_t *ctx); + void quit(nxt_unit_ctx_t *ctx); napi_value get_server_object(); @@ -35,20 +49,25 @@ private: napi_value create_request(napi_value server_obj, napi_value socket); - napi_value create_response(napi_value server_obj, napi_value socket, - napi_value request, + napi_value create_response(napi_value server_obj, napi_value request, nxt_unit_request_info_t *req); + napi_value create_websocket_frame(napi_value server_obj, + nxt_unit_websocket_frame_t *ws); + static napi_value response_send_headers(napi_env env, napi_callback_info info); static napi_value response_write(napi_env env, napi_callback_info info); static napi_value response_end(napi_env env, napi_callback_info info); + static napi_value websocket_send_frame(napi_env env, + napi_callback_info info); + static napi_value websocket_set_sock(napi_env env, napi_callback_info info); void create_headers(nxt_unit_request_info_t *req, napi_value request); void append_header(nxt_unit_field_t *f, napi_value headers, - napi_value raw_headers, uint32_t idx); + napi_value raw_headers, uint32_t idx); static napi_ref constructor_; |