/*
- * Copyright (C) 2016 "IoT.bzh"
+ * Copyright (C) 2016, 2017 "IoT.bzh"
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
return 1;
}
-int websock_dispatch(struct websock *ws)
+int websock_dispatch(struct websock *ws, int loop)
{
uint16_t code;
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)
websock_pong(ws, NULL, 0);
}
ws->state = STATE_INIT;
+ if (!loop)
+ return 0;
break;
case OPCODE_PONG:
if (ws->itf->on_pong)
else
websock_drop(ws);
ws->state = STATE_INIT;
+ if (!loop)
+ return 0;
break;
default:
goto protocol_error;