diff options
Diffstat (limited to 'src/nxt_unit.h')
-rw-r--r-- | src/nxt_unit.h | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/nxt_unit.h b/src/nxt_unit.h index 532de20d..3471a758 100644 --- a/src/nxt_unit.h +++ b/src/nxt_unit.h @@ -9,6 +9,7 @@ #include <inttypes.h> #include <sys/types.h> +#include <sys/uio.h> #include <string.h> #include "nxt_version.h" @@ -106,17 +107,24 @@ struct nxt_unit_request_info_s { void *data; }; + /* * Set of application-specific callbacks. Application may leave all optional * callbacks as NULL. */ struct nxt_unit_callbacks_s { /* - * Process request data. Unlike all other callback, this callback + * Process request. Unlike all other callback, this callback * need to be defined by application. */ void (*request_handler)(nxt_unit_request_info_t *req); + /* Process websocket frame. */ + void (*websocket_handler)(nxt_unit_websocket_frame_t *ws); + + /* Connection closed. */ + void (*close_handler)(nxt_unit_request_info_t *req); + /* Add new Unit port to communicate with process pid. Optional. */ int (*add_port)(nxt_unit_ctx_t *, nxt_unit_port_t *port); @@ -293,6 +301,14 @@ int nxt_unit_response_is_sent(nxt_unit_request_info_t *req); nxt_unit_buf_t *nxt_unit_response_buf_alloc(nxt_unit_request_info_t *req, uint32_t size); +int nxt_unit_request_is_websocket_handshake(nxt_unit_request_info_t *req); + +int nxt_unit_response_upgrade(nxt_unit_request_info_t *req); + +int nxt_unit_response_is_websocket(nxt_unit_request_info_t *req); + +nxt_unit_request_info_t *nxt_unit_get_request_info_from_data(void *data); + int nxt_unit_buf_send(nxt_unit_buf_t *buf); void nxt_unit_buf_free(nxt_unit_buf_t *buf); @@ -315,6 +331,20 @@ ssize_t nxt_unit_request_read(nxt_unit_request_info_t *req, void *dst, void nxt_unit_request_done(nxt_unit_request_info_t *req, int rc); +int nxt_unit_websocket_send(nxt_unit_request_info_t *req, uint8_t opcode, + uint8_t last, const void *start, size_t size); + +int nxt_unit_websocket_sendv(nxt_unit_request_info_t *req, uint8_t opcode, + uint8_t last, const struct iovec *iov, int iovcnt); + +ssize_t nxt_unit_websocket_read(nxt_unit_websocket_frame_t *ws, void *dst, + size_t size); + +int nxt_unit_websocket_retain(nxt_unit_websocket_frame_t *ws); + +void nxt_unit_websocket_done(nxt_unit_websocket_frame_t *ws); + + void nxt_unit_log(nxt_unit_ctx_t *ctx, int level, const char* fmt, ...); void nxt_unit_req_log(nxt_unit_request_info_t *req, int level, |