-#define CALL 2
-#define RETOK 3
-#define RETERR 4
-#define EVENT 5
-
-struct afb_wsreq
-{
- struct afb_context context;
- int refcount;
- struct afb_ws_json1 *aws;
- struct afb_wsreq *next;
- char *text;
- size_t size;
- int code;
- char *id;
- size_t idlen;
- char *api;
- size_t apilen;
- char *verb;
- size_t verblen;
- char *obj;
- size_t objlen;
- char *tok;
- size_t toklen;
- struct json_object *root;
-};
-
-static void wsreq_addref(struct afb_wsreq *wsreq);
-static void wsreq_unref(struct afb_wsreq *wsreq);
-static struct json_object *wsreq_json(struct afb_wsreq *wsreq);
-static struct afb_arg wsreq_get(struct afb_wsreq *wsreq, const char *name);
-static void wsreq_fail(struct afb_wsreq *wsreq, const char *status, const char *info);
-static void wsreq_success(struct afb_wsreq *wsreq, struct json_object *obj, const char *info);
-static const char *wsreq_raw(struct afb_wsreq *wsreq, size_t *size);
-static void wsreq_send(struct afb_wsreq *wsreq, const char *buffer, size_t size);
-
-
-static const struct afb_req_itf wsreq_itf = {
- .json = (void*)wsreq_json,
- .get = (void*)wsreq_get,
- .success = (void*)wsreq_success,
- .fail = (void*)wsreq_fail,
- .raw = (void*)wsreq_raw,
- .send = (void*)wsreq_send,
- .context_get = (void*)afb_context_get,
- .context_set = (void*)afb_context_set,
- .addref = (void*)wsreq_addref,
- .unref = (void*)wsreq_unref,
- .session_close = (void*)afb_context_close,
- .session_set_LOA = (void*)afb_context_change_loa
-};
-
-static int aws_wsreq_parse(struct afb_wsreq *r, char *text, size_t size)