summaryrefslogtreecommitdiffstats
path: root/src/websock.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-04-10 12:00:14 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-04-10 12:00:14 +0200
commit2243a0dd1adc75530bed663db808971789729df3 (patch)
treed1e003ab8b2db0c3dd9f4a685155d51be2e9681e /src/websock.c
parent5d248158cc380d0a164fa56b46a7bdede4115407 (diff)
Websocket client select if looping or not
Allows the client to tell websocket module to not loop on messages. Change-Id: Iaa1025ce5442a5659554ba66fcc5869a1e8659b4 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/websock.c')
-rw-r--r--src/websock.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/websock.c b/src/websock.c
index 04661c11..f79feb5e 100644
--- a/src/websock.c
+++ b/src/websock.c
@@ -303,7 +303,7 @@ static int check_control_header(struct websock *ws)
return 1;
}
-int websock_dispatch(struct websock *ws)
+int websock_dispatch(struct websock *ws, int loop)
{
uint16_t code;
loop:
@@ -418,16 +418,22 @@ loop:
ws->itf->on_continue(ws->closure,
FRAME_GET_FIN(ws->header[0]),
(size_t) ws->length);
+ if (!loop)
+ return 0;
break;
case OPCODE_TEXT:
ws->itf->on_text(ws->closure,
FRAME_GET_FIN(ws->header[0]),
(size_t) ws->length);
+ if (!loop)
+ return 0;
break;
case OPCODE_BINARY:
ws->itf->on_binary(ws->closure,
FRAME_GET_FIN(ws->header[0]),
(size_t) ws->length);
+ if (!loop)
+ return 0;
break;
case OPCODE_CLOSE:
if (ws->length == 0)
@@ -447,6 +453,8 @@ loop:
websock_pong(ws, NULL, 0);
}
ws->state = STATE_INIT;
+ if (!loop)
+ return 0;
break;
case OPCODE_PONG:
if (ws->itf->on_pong)
@@ -454,6 +462,8 @@ loop:
else
websock_drop(ws);
ws->state = STATE_INIT;
+ if (!loop)
+ return 0;
break;
default:
goto protocol_error;