summaryrefslogtreecommitdiffstats
path: root/src/afb-websock.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-04-08 00:11:56 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2016-04-08 00:11:56 +0200
commit54b2652e94cfa7840dbebcba46edd5459e7c6e86 (patch)
tree7ffee1167df39547c19939f496a249f47970f579 /src/afb-websock.c
parentce7b0d0a381016057cedb99f1e33293c9f65b562 (diff)
refactored websockets
Change-Id: Ic41efc1cd0b89d183c5ed36182da989548be1c8d Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-websock.c')
-rw-r--r--src/afb-websock.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/afb-websock.c b/src/afb-websock.c
index 885b986a..d92c7b00 100644
--- a/src/afb-websock.c
+++ b/src/afb-websock.c
@@ -28,6 +28,8 @@
#include "websock.h"
+#include "afb-ws-json.h"
+
#include "afb-req-itf.h"
#include "afb-method.h"
#include "afb-hreq.h"
@@ -185,12 +187,12 @@ struct afb_wsreq
struct afb_websock
{
int fd;
+ struct afb_wsreq *requests;
struct MHD_Connection *connection;
+ struct AFB_clientCtx *context;
struct websock *ws;
struct upoll *up;
- struct AFB_clientCtx *context;
struct json_tokener *tokener;
- struct afb_wsreq *requests;
};
static struct afb_arg wsreq_get(struct afb_wsreq *wsreq, const char *name);
@@ -213,6 +215,15 @@ static const struct afb_req_itf wsreq_itf = {
struct afb_websock *afb_websock_create(struct afb_hreq *hreq)
{
+ return (void*)afb_ws_json_create(
+ dup(MHD_get_connection_info(hreq->connection,MHD_CONNECTION_INFO_CONNECTION_FD)->connect_fd),
+ afb_hreq_context(hreq),
+ (void*)MHD_resume_connection,
+ hreq->connection);
+}
+
+struct afb_websock *_afb_websock_create(struct afb_hreq *hreq)
+{
int fd;
struct afb_websock *result;
@@ -226,8 +237,9 @@ struct afb_websock *afb_websock_create(struct afb_hreq *hreq)
if (result == NULL)
goto error;
- result->connection = hreq->connection;
result->fd = fd;
+ result->requests = NULL;
+ result->connection = hreq->connection;
result->context = ctxClientGet(afb_hreq_context(hreq));
if (result->context == NULL)
goto error2;