diff options
author | José Bollo <jose.bollo@iot.bzh> | 2016-04-06 15:26:04 +0200 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2016-04-06 15:26:04 +0200 |
commit | b75bbfd9bd96ad8bb7174a768ae70cf3e8c5af7a (patch) | |
tree | 0372d90b0db892cbf46caa80e18a12403cf6edc9 /src/websock.c | |
parent | 46fa94d4edd7fa874e334ab51df34f7daca007ce (diff) |
websocket first version works
Change-Id: I4db7d432ea5921636bb5033b8d31e91475cecc52
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/websock.c')
-rw-r--r-- | src/websock.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/websock.c b/src/websock.c index 41e47a0a..22e91be9 100644 --- a/src/websock.c +++ b/src/websock.c @@ -170,12 +170,12 @@ void websock_pong(struct websock *ws) void websock_text(struct websock *ws, const char *text, size_t length) { - websock_send(ws, OPCODE_TEXT, NULL, 0); + websock_send(ws, OPCODE_TEXT, text, length); } void websock_binary(struct websock *ws, const void *data, size_t length) { - websock_send(ws, OPCODE_BINARY, NULL, 0); + websock_send(ws, OPCODE_BINARY, data, length); } static int read_header(struct websock *ws) @@ -192,7 +192,7 @@ static int read_header(struct websock *ws) int websock_dispatch(struct websock *ws) { - loop: +loop: switch (ws->state) { case STATE_INIT: ws->lenhead = 0; @@ -201,7 +201,7 @@ int websock_dispatch(struct websock *ws) case STATE_START: /* read the header */ - if (!read_header(ws)) + if (read_header(ws)) return -1; else if (ws->lenhead < ws->szhead) return 0; @@ -262,7 +262,7 @@ int websock_dispatch(struct websock *ws) case STATE_LENGTH: /* continue to read the header */ - if (!read_header(ws)) + if (read_header(ws)) return -1; else if (ws->lenhead < ws->szhead) return 0; @@ -409,6 +409,7 @@ struct websock *websock_create(const struct websock_itf *itf, void *closure) if (result) { result->itf = itf; result->closure = closure; + result->maxlength = 65000; } return result; } |