X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fwebsock.h;h=82e251c1228f1366f9444adafb848e2b17371e85;hb=82adb27966eace72f810716c19c660efd7c8b15a;hp=c40a364ce45c21a65fb1158056e0590f6423f3bf;hpb=54b2652e94cfa7840dbebcba46edd5459e7c6e86;p=src%2Fapp-framework-binder.git diff --git a/src/websock.h b/src/websock.h index c40a364c..82e251c1 100644 --- a/src/websock.h +++ b/src/websock.h @@ -21,6 +21,8 @@ * Copyright 2010-2012 self.disconnect (APACHE-2) */ +#pragma once + struct iovec; #define WEBSOCKET_CODE_OK 1000 @@ -38,29 +40,35 @@ struct iovec; struct websock_itf { ssize_t (*writev) (void *, const struct iovec *, int); ssize_t (*readv) (void *, const struct iovec *, int); - void (*disconnect) (void *); - void (*on_ping) (void *); /* if not NULL, responsible of pong */ - void (*on_pong) (void *); + void (*on_ping) (void *, size_t size); /* optional, if not NULL, responsible of pong */ + void (*on_pong) (void *, size_t size); /* optional */ void (*on_close) (void *, uint16_t code, size_t size); void (*on_text) (void *, int last, size_t size); void (*on_binary) (void *, int last, size_t size); void (*on_continue) (void *, int last, size_t size); int (*on_extension) (void *, int last, int rsv1, int rsv2, int rsv3, int opcode, size_t size); + + void (*on_error) (void *, uint16_t code, const void *data, size_t size); /* optional */ }; struct websock; -void websock_close(struct websock *ws); -void websock_close_code(struct websock *ws, uint16_t code); +int websock_close_empty(struct websock *ws); +int websock_close(struct websock *ws, uint16_t code, const void *data, size_t length); +int websock_error(struct websock *ws, uint16_t code, const void *data, size_t length); -void websock_ping(struct websock *ws); -void websock_pong(struct websock *ws); -void websock_text(struct websock *ws, const char *text, size_t length); -void websock_binary(struct websock *ws, const void *data, size_t length); +int websock_ping(struct websock *ws, const void *data, size_t length); +int websock_pong(struct websock *ws, const void *data, size_t length); +int websock_text(struct websock *ws, int last, const void *text, size_t length); +int websock_text_v(struct websock *ws, int last, const struct iovec *iovec, int count); +int websock_binary(struct websock *ws, int last, const void *data, size_t length); +int websock_binary_v(struct websock *ws, int last, const struct iovec *iovec, int count); +int websock_continue(struct websock *ws, int last, const void *data, size_t length); +int websock_continue_v(struct websock *ws, int last, const struct iovec *iovec, int count); ssize_t websock_read(struct websock *ws, void *buffer, size_t size); -void websock_drop(struct websock *ws); +int websock_drop(struct websock *ws); int websock_dispatch(struct websock *ws);