diff options
| author | Garrett D'Amore <garrett@damore.org> | 2019-01-21 22:40:10 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2019-02-16 19:22:27 -0800 |
| commit | 5cf750697624d4fd63cfe26921209d7c30e1a2d2 (patch) | |
| tree | bf11695e5f1ec5e400c87da0cc6ff23935a2eeff /src/supplemental/websocket/websocket.h | |
| parent | ca655b9db689ee0e655248b1a9f166b8db6cc984 (diff) | |
| download | nng-5cf750697624d4fd63cfe26921209d7c30e1a2d2.tar.gz nng-5cf750697624d4fd63cfe26921209d7c30e1a2d2.tar.bz2 nng-5cf750697624d4fd63cfe26921209d7c30e1a2d2.zip | |
fixes #872 create unified nng_stream API
This is a major change, and includes changes to use a polymorphic
stream API for all transports. There have been related bugs fixed
along the way. Additionally the man pages have changed.
The old non-polymorphic APIs are removed now. This is a breaking
change, but the old APIs were never part of any released public API.
Diffstat (limited to 'src/supplemental/websocket/websocket.h')
| -rw-r--r-- | src/supplemental/websocket/websocket.h | 53 |
1 files changed, 11 insertions, 42 deletions
diff --git a/src/supplemental/websocket/websocket.h b/src/supplemental/websocket/websocket.h index 88b4bfb4..bbc58d30 100644 --- a/src/supplemental/websocket/websocket.h +++ b/src/supplemental/websocket/websocket.h @@ -1,7 +1,7 @@ // -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2019 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> -// Copyright 2018 Devolutions <info@devolutions.net> +// Copyright 2019 Devolutions <info@devolutions.net> // // This software is supplied under the terms of the MIT License, a // copy of which should be located in the distribution where this @@ -18,7 +18,10 @@ typedef struct nni_ws nni_ws; typedef struct nni_ws_listener nni_ws_listener; typedef struct nni_ws_dialer nni_ws_dialer; -typedef int (*nni_ws_listen_hook)(void *, nng_http_req *, nng_http_res *); +// Internal option, not for normal use (at present). This sets the +// dialer/listener into message mode. This is used by the SP transport. +// This is a boolean. +#define NNI_OPT_WS_MSGMODE "ws:msgmode" // Specify URL as ws://[<host>][:port][/path] // If host is missing, INADDR_ANY is assumed. If port is missing, @@ -26,44 +29,10 @@ typedef int (*nni_ws_listen_hook)(void *, nng_http_req *, nng_http_res *); // on INADDR_ANY port 80, with path "/". For connect side, INADDR_ANY // makes no sense. (TBD: return NNG_EADDRINVAL, or try loopback?) -extern int nni_ws_listener_init(nni_ws_listener **, nni_url *); -extern void nni_ws_listener_fini(nni_ws_listener *); -extern void nni_ws_listener_close(nni_ws_listener *); -extern int nni_ws_listener_proto(nni_ws_listener *, const char *); -extern int nni_ws_listener_listen(nni_ws_listener *); -extern void nni_ws_listener_accept(nni_ws_listener *, nng_aio *); -extern void nni_ws_listener_hook( - nni_ws_listener *, nni_ws_listen_hook, void *); -extern int nni_ws_listener_set_tls(nni_ws_listener *, nng_tls_config *); -extern int nni_ws_listener_get_tls(nni_ws_listener *, nng_tls_config **s); -extern void nni_ws_listener_set_maxframe(nni_ws_listener *, size_t); - -extern int nni_ws_dialer_init(nni_ws_dialer **, nni_url *); -extern void nni_ws_dialer_fini(nni_ws_dialer *); -extern void nni_ws_dialer_close(nni_ws_dialer *); -extern int nni_ws_dialer_proto(nni_ws_dialer *, const char *); -extern int nni_ws_dialer_header(nni_ws_dialer *, const char *, const char *); -extern void nni_ws_dialer_set_maxframe(nni_ws_dialer *, size_t); -extern void nni_ws_dialer_dial(nni_ws_dialer *, nng_aio *); -extern int nni_ws_dialer_set_tls(nni_ws_dialer *, nng_tls_config *); -extern int nni_ws_dialer_get_tls(nni_ws_dialer *, nng_tls_config **); - -// Dialer does not get a hook chance, as it can examine the request and reply -// after dial is done; this is not a 3-way handshake, so the dialer does -// not confirm the server's response at the HTTP level. (It can still issue -// a websocket close). - -extern void nni_ws_send_msg(nni_ws *, nng_aio *); -extern void nni_ws_recv_msg(nni_ws *, nng_aio *); -extern void nni_ws_close(nni_ws *); -extern void nni_ws_close_error(nni_ws *, uint16_t); -extern void nni_ws_fini(nni_ws *); -extern const char *nni_ws_response_headers(nni_ws *); -extern const char *nni_ws_request_headers(nni_ws *); -extern int nni_ws_getopt(nni_ws *, const char *, void *, size_t *, nni_type); -extern int nni_ws_setopt( - nni_ws *, const char *, const void *, size_t, nni_type); - -// The implementation will send periodic PINGs, and respond with PONGs. +// Much of the websocket API is still "private", meeaning you should not +// rely upon it being around. +extern int nni_ws_listener_alloc(nng_stream_listener **, const nni_url *); +extern int nni_ws_dialer_alloc(nng_stream_dialer **, const nni_url *); +extern int nni_ws_checkopt(const char *, const void *, size_t, nni_type); #endif // NNG_SUPPLEMENTAL_WEBSOCKET_WEBSOCKET_H |
