X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-ws.h;h=a32363ed5ff9858aced8e0c3ddcd4e21176e5006;hb=65353dce81a629e042800bb7b86fcd869a76727e;hp=1faec65ce05e458bb4f109c88d5fbea33acb11c7;hpb=68a8eaafe5f43480f29308bfd2ec12ad54da43f1;p=src%2Fapp-framework-binder.git diff --git a/src/afb-ws.h b/src/afb-ws.h index 1faec65c..a32363ed 100644 --- a/src/afb-ws.h +++ b/src/afb-ws.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 IoT.bzh + * Copyright (C) 2015-2020 "IoT.bzh" * Author: José Bollo * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,16 +18,27 @@ #pragma once struct afb_ws; +struct fdev; +struct iovec; struct afb_ws_itf { - void (*on_close) (void *, uint16_t code, char *, size_t size); + 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_close(struct afb_ws *ws, uint16_t code); -extern void afb_ws_text(struct afb_ws *ws, const char *text, size_t length); -extern void afb_ws_binary(struct afb_ws *ws, const void *data, size_t length); +extern struct afb_ws *afb_ws_create(struct fdev *fdev, 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_is_connected(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); +extern int afb_ws_text_v(struct afb_ws *ws, const struct iovec *iovec, int count); +extern int afb_ws_binary_v(struct afb_ws *ws, const struct iovec *iovec, int count);