aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-08-03 15:13:59 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2016-08-03 15:13:59 +0200
commite22f8536c5f8833828a6d5cb8f5a77a8c0712e08 (patch)
tree49f6f5c4a07e266d19eb307d86b46fa891308436
parent8e62dd65bcc04910e46f47fb8f098d37f19f25c4 (diff)
afb-ws: adds function afb_ws_is_connected
Change-Id: If7f3a2b9a724f28dbd3e4968347892d837ba875d Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afb-ws.c8
-rw-r--r--src/afb-ws.h1
2 files changed, 9 insertions, 0 deletions
diff --git a/src/afb-ws.c b/src/afb-ws.c
index a7582794..c25c3f10 100644
--- a/src/afb-ws.c
+++ b/src/afb-ws.c
@@ -201,6 +201,14 @@ void afb_ws_hangup(struct afb_ws *ws)
}
/*
+ * Is the websocket 'ws' still connected ?
+ */
+int afb_ws_is_connected(struct afb_ws *ws)
+{
+ return ws->ws != NULL;
+}
+
+/*
* Sends a 'close' command to the endpoint of 'ws' with the 'code' and the
* 'reason' (that can be NULL and that else should not be greater than 123
* characters).
diff --git a/src/afb-ws.h b/src/afb-ws.h
index af435ea6..5ba3cc1a 100644
--- a/src/afb-ws.h
+++ b/src/afb-ws.h
@@ -33,6 +33,7 @@ struct afb_ws_itf
extern struct afb_ws *afb_ws_create(struct sd_event *eloop, 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_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);