Allows the client to tell websocket module to not
loop on messages.
Change-Id: Iaa1025ce5442a5659554ba66fcc5869a1e8659b4
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
int rc;
assert(ws->ws != NULL);
int rc;
assert(ws->ws != NULL);
- rc = websock_dispatch(ws->ws);
+ rc = websock_dispatch(ws->ws, 0);
if (rc < 0 && errno == EPIPE)
afb_ws_hangup(ws);
}
if (rc < 0 && errno == EPIPE)
afb_ws_hangup(ws);
}
-int websock_dispatch(struct websock *ws)
+int websock_dispatch(struct websock *ws, int loop)
ws->itf->on_continue(ws->closure,
FRAME_GET_FIN(ws->header[0]),
(size_t) ws->length);
ws->itf->on_continue(ws->closure,
FRAME_GET_FIN(ws->header[0]),
(size_t) ws->length);
break;
case OPCODE_TEXT:
ws->itf->on_text(ws->closure,
FRAME_GET_FIN(ws->header[0]),
(size_t) ws->length);
break;
case OPCODE_TEXT:
ws->itf->on_text(ws->closure,
FRAME_GET_FIN(ws->header[0]),
(size_t) ws->length);
break;
case OPCODE_BINARY:
ws->itf->on_binary(ws->closure,
FRAME_GET_FIN(ws->header[0]),
(size_t) ws->length);
break;
case OPCODE_BINARY:
ws->itf->on_binary(ws->closure,
FRAME_GET_FIN(ws->header[0]),
(size_t) ws->length);
break;
case OPCODE_CLOSE:
if (ws->length == 0)
break;
case OPCODE_CLOSE:
if (ws->length == 0)
websock_pong(ws, NULL, 0);
}
ws->state = STATE_INIT;
websock_pong(ws, NULL, 0);
}
ws->state = STATE_INIT;
break;
case OPCODE_PONG:
if (ws->itf->on_pong)
break;
case OPCODE_PONG:
if (ws->itf->on_pong)
else
websock_drop(ws);
ws->state = STATE_INIT;
else
websock_drop(ws);
ws->state = STATE_INIT;
break;
default:
goto protocol_error;
break;
default:
goto protocol_error;
extern ssize_t websock_read(struct websock *ws, void *buffer, size_t size);
extern int websock_drop(struct websock *ws);
extern ssize_t websock_read(struct websock *ws, void *buffer, size_t size);
extern int websock_drop(struct websock *ws);
-extern int websock_dispatch(struct websock *ws);
+extern int websock_dispatch(struct websock *ws, int loop);
extern struct websock *websock_create_v13(const struct websock_itf *itf, void *closure);
extern void websock_destroy(struct websock *ws);
extern struct websock *websock_create_v13(const struct websock_itf *itf, void *closure);
extern void websock_destroy(struct websock *ws);