-/*
- * Copyright (C) 2015, 2016 "IoT.bzh"
+/*
+ * Copyright (C) 2015, 2016, 2017 "IoT.bzh"
* Author José Bollo <jose.bollo@iot.bzh>
*
* Licensed under the Apache License, Version 2.0 (the "License");
#include "afb-common.h"
-#include "session.h"
+#include "afb-session.h"
#include "afb-msg-json.h"
#include "afb-apis.h"
#include "afb-api-so.h"
rc = sd_bus_message_append(msg, "ssu",
afb_req_raw(req, &size),
- ctxClientGetUuid(context->session),
+ afb_session_uuid(context->session),
(uint32_t)context->flags);
if (rc < 0)
goto error;
free(listener);
}
-static struct listener *afb_api_dbus_server_listerner_get(struct api_dbus *api, const char *sender, struct AFB_clientCtx *session)
+static struct listener *afb_api_dbus_server_listerner_get(struct api_dbus *api, const char *sender, struct afb_session *session)
{
int rc;
struct listener *listener;
return NULL;
/* retrieves the stored listener */
- listener = ctxClientCookieGet(session, destination);
+ listener = afb_session_get_cookie(session, destination);
if (listener != NULL) {
/* found */
afb_api_dbus_server_destination_unref(destination);
listener->destination = destination;
listener->listener = afb_evt_listener_create(&evt_push_itf, destination);
if (listener->listener != NULL) {
- rc = ctxClientCookieSet(session, destination, listener, (void*)afb_api_dbus_server_listener_free);
+ rc = afb_session_set_cookie(session, destination, listener, (void*)afb_api_dbus_server_listener_free);
if (rc == 0)
return listener;
afb_evt_listener_unref(listener->listener);
{
if (dreq->json == NULL) {
dreq->json = json_tokener_parse(dreq->request);
- if (dreq->json == NULL) {
+ if (dreq->json == NULL && strcmp(dreq->request, "null")) {
/* lazy error detection of json request. Is it to improve? */
dreq->json = json_object_new_string(dreq->request);
}
{
const char *data = json_object_to_json_string_ext(object, JSON_C_TO_STRING_PLAIN);
afb_api_dbus_server_event_send(closure, '!', event, eventid, data, 0);
+ json_object_put(object);
}
static void afb_api_dbus_server_event_broadcast(void *closure, const char *event, int eventid, struct json_object *object)
struct api_dbus *api = userdata;
struct afb_req areq;
uint32_t flags;
- struct AFB_clientCtx *session;
+ struct afb_session *session;
struct listener *listener;
/* check the interface */