int afb_xreq_subscribe(struct afb_xreq *xreq, struct afb_event_x2 *event)
{
- if (xreq->listener)
- return afb_evt_event_x2_add_watch(xreq->listener, event);
- if (xreq->queryitf->subscribe)
- return xreq->queryitf->subscribe(xreq, event);
- ERROR("no event listener, subscription impossible");
- errno = EINVAL;
+ if (xreq->replied) {
+ ERROR("request replied, subscription impossible");
+ errno = EINVAL;
+ } else {
+ if (xreq->queryitf->subscribe)
+ return xreq->queryitf->subscribe(xreq, event);
+ ERROR("no event listener, subscription impossible");
+ errno = ENOTSUP;
+ }
return -1;
}
int afb_xreq_unsubscribe(struct afb_xreq *xreq, struct afb_event_x2 *event)
{
- if (xreq->listener)
- return afb_evt_event_x2_remove_watch(xreq->listener, event);
- if (xreq->queryitf->unsubscribe)
- return xreq->queryitf->unsubscribe(xreq, event);
- ERROR("no event listener, unsubscription impossible");
- errno = EINVAL;
+ if (xreq->replied) {
+ ERROR("request replied, unsubscription impossible");
+ errno = EINVAL;
+ } else {
+ if (xreq->queryitf->unsubscribe)
+ return xreq->queryitf->unsubscribe(xreq, event);
+ ERROR("no event listener, unsubscription impossible");
+ errno = ENOTSUP;
+ }
return -1;
}
json_object_object_add(r, "id", json_object_new_string(xreq->cred->id));
}
if (xreq->context.session) {
- json_object_object_add(r, "uuid", json_object_new_string(afb_context_uuid(&xreq->context)));
+ json_object_object_add(r, "uuid", json_object_new_string(afb_context_uuid(&xreq->context)?:""));
json_object_object_add(r, "LOA", json_object_new_int(afb_context_get_loa(&xreq->context)));
}
return r;
}
}
- if ((sessionflags & AFB_SESSION_RENEW_X1) != 0) {
- afb_context_refresh(&xreq->context);
- }
if ((sessionflags & AFB_SESSION_CLOSE_X1) != 0) {
afb_context_change_loa(&xreq->context, 0);
afb_context_close(&xreq->context);
return -1;
}
- if ((sessionflags & AFB_SESSION_REFRESH_X2) != 0) {
- afb_context_refresh(&xreq->context);
- }
if ((sessionflags & AFB_SESSION_CLOSE_X2) != 0) {
afb_context_close(&xreq->context);
}