X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-ws.h;h=48df9e4f5b3e728263e1f20464a126e1b14730b2;hb=146f95b776c7a424e672b27386fbb8392bc0ffb7;hp=6350fb9eb60b5c1b8d5284096341f67f2f579d4c;hpb=911df9d068b3e259dcab970ded4132a7397f565f;p=src%2Fapp-framework-binder.git diff --git a/src/afb-ws.h b/src/afb-ws.h index 6350fb9e..48df9e4f 100644 --- a/src/afb-ws.h +++ b/src/afb-ws.h @@ -15,6 +15,25 @@ * limitations under the License. */ +#pragma once + struct afb_ws; +struct afb_ws_itf +{ + void (*on_close) (void *, uint16_t code, char *, size_t size); /* optional, if not set hangup is called */ + void (*on_text) (void *, char *, size_t size); + void (*on_binary) (void *, char *, size_t size); + void (*on_error) (void *, uint16_t code, const void *, size_t size); /* optional, if not set hangup is called */ + void (*on_hangup) (void *); /* optional, it is safe too call afb_ws_destroy within the callback */ +}; + +extern struct afb_ws *afb_ws_create(int fd, const struct afb_ws_itf *itf, void *closure); +extern void afb_ws_destroy(struct afb_ws *ws); +extern void afb_ws_hangup(struct afb_ws *ws); +extern int afb_ws_close(struct afb_ws *ws, uint16_t code, const char *reason); +extern int afb_ws_error(struct afb_ws *ws, uint16_t code, const char *reason); +extern int afb_ws_text(struct afb_ws *ws, const char *text, size_t length); +extern int afb_ws_texts(struct afb_ws *ws, ...); +extern int afb_ws_binary(struct afb_ws *ws, const void *data, size_t length);