2 * Copyright (C) 2016 "IoT.bzh"
3 * Author: José Bollo <jose.bollo@iot.bzh>
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
20 #include <json-c/json.h>
22 #include "afb-msg-json.h"
25 struct json_object *afb_msg_json_reply(const char *status, const char *info, struct json_object *resp, const char *token, const char *uuid)
27 json_object *msg, *request;
29 request = json_object_new_object();
30 json_object_object_add(request, "status", json_object_new_string(status));
32 json_object_object_add(request, "info", json_object_new_string(info));
34 json_object_object_add(request, "token", json_object_new_string(token));
36 json_object_object_add(request, "uuid", json_object_new_string(uuid));
38 msg = json_object_new_object();
39 json_object_object_add(msg, "jtype", json_object_new_string("afb-reply"));
40 json_object_object_add(msg, "request", request);
42 json_object_object_add(msg, "response", resp);
47 struct json_object *afb_msg_json_event(const char *event, struct json_object *object)
51 msg = json_object_new_object();
52 json_object_object_add(msg, "jtype", json_object_new_string("afb-event"));
53 json_object_object_add(msg, "event", json_object_new_string(event));
55 json_object_object_add(msg, "data", object);