X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-proto-ws.h;h=506960eab1ed9149c6c884bb364b9a11453cfa26;hb=6dfeafe7e4fa582b3db3f950136bc97f8611fc6d;hp=cef7eadb3761a255abd9e285f0a6b0ce6c2b1b7c;hpb=ca820c65c2b03a24e8936218171c6c1d138fd1f7;p=src%2Fapp-framework-binder.git diff --git a/src/afb-proto-ws.h b/src/afb-proto-ws.h index cef7eadb..506960ea 100644 --- a/src/afb-proto-ws.h +++ b/src/afb-proto-ws.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017 "IoT.bzh" + * Copyright (C) 2016-2019 "IoT.bzh" * Author: José Bollo * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,17 +18,23 @@ #pragma once +/* + * Defined since version 3, the value AFB_PROTO_WS_VERSION can be used to + * track versions of afb-proto-ws. + */ +#define AFB_PROTO_WS_VERSION 3 + struct fdev; struct afb_proto_ws; struct afb_proto_ws_call; -struct afb_proto_ws_subcall; struct afb_proto_ws_describe; +typedef unsigned char afb_proto_ws_uuid_t[16]; + struct afb_proto_ws_client_itf { /* can't be NULL */ - void (*on_reply_success)(void *closure, void *request, struct json_object *result, const char *info); - void (*on_reply_fail)(void *closure, void *request, const char *status, const char *info); + void (*on_reply)(void *closure, void *request, struct json_object *obj, const char *error, const char *info); /* can be NULL */ void (*on_event_create)(void *closure, const char *event_name, int event_id); @@ -36,14 +42,12 @@ struct afb_proto_ws_client_itf void (*on_event_subscribe)(void *closure, void *request, const char *event_name, int event_id); void (*on_event_unsubscribe)(void *closure, void *request, const char *event_name, int event_id); void (*on_event_push)(void *closure, const char *event_name, int event_id, struct json_object *data); - void (*on_event_broadcast)(void *closure, const char *event_name, struct json_object *data); - - void (*on_subcall)(void *closure, struct afb_proto_ws_subcall *subcall, void *request, const char *api, const char *verb, struct json_object *args); + void (*on_event_broadcast)(void *closure, const char *event_name, struct json_object *data, const afb_proto_ws_uuid_t uuid, uint8_t hop); }; struct afb_proto_ws_server_itf { - void (*on_call)(void *closure, struct afb_proto_ws_call *call, const char *verb, struct json_object *args, const char *sessionid); + void (*on_call)(void *closure, struct afb_proto_ws_call *call, const char *verb, struct json_object *args, const char *sessionid, const char *user_creds); void (*on_describe)(void *closure, struct afb_proto_ws_describe *describe); }; @@ -57,29 +61,25 @@ extern int afb_proto_ws_is_client(struct afb_proto_ws *protows); extern int afb_proto_ws_is_server(struct afb_proto_ws *protows); extern void afb_proto_ws_hangup(struct afb_proto_ws *protows); -extern void afb_proto_ws_on_hangup(struct afb_proto_ws *protows, void (*on_hangup)(void *closure)); +extern void afb_proto_ws_on_hangup(struct afb_proto_ws *protows, void (*on_hangup)(void *closure)); +extern void afb_proto_ws_set_queuing(struct afb_proto_ws *protows, int (*queuing)(struct afb_proto_ws *, void (*)(int,void*), void*)); -extern int afb_proto_ws_client_call(struct afb_proto_ws *protows, const char *verb, struct json_object *args, const char *sessionid, void *request); +extern int afb_proto_ws_client_call(struct afb_proto_ws *protows, const char *verb, struct json_object *args, const char *sessionid, void *request, const char *user_creds); extern int afb_proto_ws_client_describe(struct afb_proto_ws *protows, void (*callback)(void*, struct json_object*), void *closure); extern int afb_proto_ws_server_event_create(struct afb_proto_ws *protows, const char *event_name, int event_id); extern int afb_proto_ws_server_event_remove(struct afb_proto_ws *protows, const char *event_name, int event_id); extern int afb_proto_ws_server_event_push(struct afb_proto_ws *protows, const char *event_name, int event_id, struct json_object *data); -extern int afb_proto_ws_server_event_broadcast(struct afb_proto_ws *protows, const char *event_name, struct json_object *data); +extern int afb_proto_ws_server_event_broadcast(struct afb_proto_ws *protows, const char *event_name, struct json_object *data, const afb_proto_ws_uuid_t uuid, uint8_t hop); extern void afb_proto_ws_call_addref(struct afb_proto_ws_call *call); extern void afb_proto_ws_call_unref(struct afb_proto_ws_call *call); -extern int afb_proto_ws_call_success(struct afb_proto_ws_call *call, struct json_object *obj, const char *info); -extern int afb_proto_ws_call_fail(struct afb_proto_ws_call *call, const char *status, const char *info); +extern int afb_proto_ws_call_reply(struct afb_proto_ws_call *call, struct json_object *obj, const char *error, const char *info); -extern int afb_proto_ws_call_subcall(struct afb_proto_ws_call *call, const char *api, const char *verb, struct json_object *args, void (*callback)(void*, int, struct json_object*), void *cb_closure); extern int afb_proto_ws_call_subscribe(struct afb_proto_ws_call *call, const char *event_name, int event_id); extern int afb_proto_ws_call_unsubscribe(struct afb_proto_ws_call *call, const char *event_name, int event_id); -extern int afb_proto_ws_subcall_reply(struct afb_proto_ws_subcall *subcall, int status, struct json_object *result); - extern int afb_proto_ws_describe_put(struct afb_proto_ws_describe *describe, struct json_object *description); -