aboutsummaryrefslogtreecommitdiffstats
path: root/bindings
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2018-06-22 18:00:44 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2018-06-22 18:05:35 +0200
commit176d14b5b4ec6338c9da5b7f55dce32f335245ae (patch)
tree12aaadb14628f8c91cdf0b6107459b0a4dfafaed /bindings
parentcd6d4492a271951c856ce611b88df0b4cc0ae7f0 (diff)
hello3: Add verbs
Add the following verb for testing purpose: - close: close the session - set-loa: set the LOA of the session - setctx: set the contextual data of a session - setctxif: set the contextual data of a session if not already set - getctx: get the contextual data of a session - info: returns the info of the session Change-Id: Ie2ceb897ecdff01f6efd0a3b174b5794913726d9 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'bindings')
-rw-r--r--bindings/samples/hello3.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/bindings/samples/hello3.c b/bindings/samples/hello3.c
index 0136d223..b641b05a 100644
--- a/bindings/samples/hello3.c
+++ b/bindings/samples/hello3.c
@@ -421,6 +421,37 @@ static void uid (afb_req_t request)
afb_req_success_f(request, json_object_new_int(uid), "uid is %d", uid);
}
+static void closess (afb_req_t request)
+{
+ afb_req_session_close(request);
+ afb_req_reply(request, NULL, NULL, "session closed");
+}
+
+static void setloa (afb_req_t request)
+{
+ int loa = json_object_get_int(afb_req_json(request));
+ afb_req_session_set_LOA(request, loa);
+ afb_req_reply_f(request, NULL, NULL, "LOA set to %d", loa);
+}
+
+static void setctx (afb_req_t request)
+{
+ struct json_object *x = afb_req_json(request);
+ afb_req_context(request, (int)(intptr_t)afb_req_get_vcbdata(request), (void*)json_object_get, (void*)json_object_put, x);
+ afb_req_reply(request, json_object_get(x), NULL, "context set");
+}
+
+static void getctx (afb_req_t request)
+{
+ struct json_object *x = afb_req_context(request, 0, 0, 0, 0);
+ afb_req_reply(request, json_object_get(x), NULL, "returning the context");
+}
+
+static void info (afb_req_t request)
+{
+ afb_req_reply(request, afb_req_get_client_info(request), NULL, NULL);
+}
+
static int preinit(afb_api_t api)
{
AFB_NOTICE("hello binding comes to live");
@@ -463,6 +494,12 @@ static const struct afb_verb_v3 verbs[]= {
{ .verb="appid", .callback=appid },
{ .verb="uid", .callback=uid },
{ .verb="exit", .callback=exitnow },
+ { .verb="close", .callback=closess },
+ { .verb="set-loa", .callback=setloa },
+ { .verb="setctx", .callback=setctx, .vcbdata = (void*)(intptr_t)1 },
+ { .verb="setctxif", .callback=setctx, .vcbdata = (void*)(intptr_t)0 },
+ { .verb="getctx", .callback=getctx },
+ { .verb="info", .callback=info },
{ .verb=NULL}
};