summaryrefslogtreecommitdiffstats
path: root/src/afb-websock.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-04-07 19:57:25 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2016-04-07 19:57:25 +0200
commit911df9d068b3e259dcab970ded4132a7397f565f (patch)
treeaa514a649d95c13fa6dffa048584ff35d7870464 /src/afb-websock.c
parent5d088cbac7130e9ec8655218acb15dd22b20a7f8 (diff)
improves websockets
Change-Id: I5b941a043838d438c0acc31623ce9361fa742f35 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-websock.c')
-rw-r--r--src/afb-websock.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/afb-websock.c b/src/afb-websock.c
index 878df042..1f800717 100644
--- a/src/afb-websock.c
+++ b/src/afb-websock.c
@@ -170,7 +170,8 @@ static struct websock_itf aws_itf = {
.on_close = (void*)aws_on_close,
.on_text = (void*)aws_on_content,
.on_binary = (void*)aws_on_content,
- .on_continue = (void*)aws_on_content
+ .on_continue = (void*)aws_on_content,
+ .on_extension = NULL,
};
struct afb_wsreq
@@ -235,23 +236,25 @@ struct afb_websock *afb_websock_create(struct afb_hreq *hreq)
result->tokener = json_tokener_new();
if (result->tokener == NULL)
- goto error2;
+ goto error3;
- result->ws = websock_create(&aws_itf, result);
+ result->ws = websock_create_v13(&aws_itf, result);
if (result->ws == NULL)
- goto error3;
+ goto error4;
result->up = upoll_open(result->fd, result);
if (result->up == NULL)
- goto error4;
+ goto error5;
upoll_on_readable(result->up, (void*)aws_on_readable);
upoll_on_hangup(result->up, (void*)aws_disconnect);
return result;
-error4:
+error5:
websock_destroy(result->ws);
-error3:
+error4:
json_tokener_free(result->tokener);
+error3:
+ ctxClientPut(result->context);
error2:
free(result);
error:
@@ -301,7 +304,7 @@ static void aws_on_readable(struct afb_websock *ws)
static int aws_handle_json(struct afb_websock *aws, struct json_object *obj)
{
struct afb_req r;
- int count, num, rc;
+ int count, num;
struct json_object *type, *id, *name, *req, *token;
struct afb_wsreq *wsreq;
const char *api, *verb;
@@ -403,7 +406,6 @@ static void aws_on_content(struct afb_websock *ws, int last, size_t size)
}
}
-
static struct afb_arg wsreq_get(struct afb_wsreq *wsreq, const char *name)
{
struct afb_arg arg;