-static void client_reply_success(struct afb_stub_ws *stubws, struct readbuf *rb)
-{
- struct client_call *call;
- struct json_object *object;
- const char *info;
- uint32_t flags;
-
- /* retrieve the message data */
- if (!client_msg_call_get(stubws, rb, &call))
- return;
-
- if (readbuf_uint32(rb, &flags)
- && readbuf_string(rb, &info, NULL)
- && readbuf_object(rb, &object)) {
- call->xreq->context.flags = (unsigned)flags;
- afb_xreq_success(call->xreq, object, *info ? info : NULL);
- } else {
- /* failing to have the answer */
- afb_xreq_fail(call->xreq, "error", "ws error");
- }
- client_call_destroy(call);
-}
-
-static void client_reply_fail(struct afb_stub_ws *stubws, struct readbuf *rb)
-{
- struct client_call *call;
- const char *info, *status;
- uint32_t flags;
-
- /* retrieve the message data */
- if (!client_msg_call_get(stubws, rb, &call))
- return;
-
- if (readbuf_uint32(rb, &flags)
- && readbuf_string(rb, &status, NULL)
- && readbuf_string(rb, &info, NULL)) {
- call->xreq->context.flags = (unsigned)flags;
- afb_xreq_fail(call->xreq, status, *info ? info : NULL);
- } else {
- /* failing to have the answer */
- afb_xreq_fail(call->xreq, "error", "ws error");
- }
- client_call_destroy(call);
-}
-
-/* send a subcall reply */
-static void client_send_subcall_reply(struct client_subcall *subcall, int status, json_object *object)
-{
- int rc;
- struct writebuf wb = { .count = 0 };
- char ie = status < 0;
-
- if (!writebuf_char(&wb, CHAR_FOR_SUBCALL_REPLY)
- || !writebuf_uint32(&wb, subcall->subcallid)
- || !writebuf_char(&wb, ie)
- || !writebuf_object(&wb, object)) {
- /* write error ? */
- return;
- }
-
- rc = afb_ws_binary_v(subcall->stubws->ws, wb.iovec, wb.count);
- if (rc >= 0)
- return;
- ERROR("error while sending subcall reply");
-}
-
-/* callback for subcall reply */
-static void client_subcall_reply_cb(void *closure, int status, json_object *object)