Code Review
/
src
/
app-framework-binder.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Bindings V2: migration of HelloWorld binder
[src/app-framework-binder.git]
/
src
/
websock.c
diff --git
a/src/websock.c
b/src/websock.c
index
1b886c1
..
f79feb5
100644
(file)
--- a/
src/websock.c
+++ b/
src/websock.c
@@
-1,5
+1,5
@@
/*
/*
- * 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.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-303,7
+303,7
@@
static int check_control_header(struct websock *ws)
return 1;
}
return 1;
}
-int websock_dispatch(struct websock *ws)
+int websock_dispatch(struct websock *ws
, int loop
)
{
uint16_t code;
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);
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);
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);
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)
break;
case OPCODE_CLOSE:
if (ws->length == 0)
@@
-447,6
+453,8
@@
loop:
websock_pong(ws, NULL, 0);
}
ws->state = STATE_INIT;
websock_pong(ws, NULL, 0);
}
ws->state = STATE_INIT;
+ if (!loop)
+ return 0;
break;
case OPCODE_PONG:
if (ws->itf->on_pong)
break;
case OPCODE_PONG:
if (ws->itf->on_pong)
@@
-454,6
+462,8
@@
loop:
else
websock_drop(ws);
ws->state = STATE_INIT;
else
websock_drop(ws);
ws->state = STATE_INIT;
+ if (!loop)
+ return 0;
break;
default:
goto protocol_error;
break;
default:
goto protocol_error;
@@
-537,7
+547,7
@@
int websock_drop(struct websock *ws)
char buffer[8000];
while (ws->length)
char buffer[8000];
while (ws->length)
- if (w
s
_read(ws, buffer, sizeof buffer) < 0)
+ if (w
ebsock
_read(ws, buffer, sizeof buffer) < 0)
return -1;
return 0;
}
return -1;
return 0;
}