#pragma once
-struct json_object;
struct afb_session;
-extern void afb_session_init(int max_session_count, int timeout, const char *initok, int context_count);
+#define AFB_SESSION_TIMEOUT_INFINITE -1
+#define AFB_SESSION_TIMEOUT_DEFAULT -2
+#define AFB_SESSION_TIMEOUT_IS_VALID(x) ((x) >= AFB_SESSION_TIMEOUT_DEFAULT)
-extern struct afb_session *afb_session_create (const char *uuid, int timeout);
-extern struct afb_session *afb_session_get (const char *uuid, int *created);
+extern void afb_session_init(int max_session_count, int timeout, const char *initok);
+extern const char *afb_session_initial_token();
+
+extern struct afb_session *afb_session_create (int timeout);
+extern struct afb_session *afb_session_search (const char *uuid);
+extern struct afb_session *afb_session_get (const char *uuid, int timeout, int *created);
extern const char *afb_session_uuid (struct afb_session *session);
extern struct afb_session *afb_session_addref(struct afb_session *session);
extern void afb_session_unref(struct afb_session *session);
+extern void afb_session_set_autoclose(struct afb_session *session, int autoclose);
extern void afb_session_close(struct afb_session *session);
+extern int afb_session_is_active (struct afb_session *session);
+extern int afb_session_is_closed (struct afb_session *session);
extern int afb_session_check_token(struct afb_session *session, const char *token);
extern void afb_session_new_token(struct afb_session *session);
extern const char *afb_session_token(struct afb_session *session);
-extern unsigned afb_session_get_LOA(struct afb_session *session);
-extern void afb_session_set_LOA (struct afb_session *session, unsigned loa);
-
-extern void *afb_session_get_value(struct afb_session *session, int index);
-extern void afb_session_set_value(struct afb_session *session, int index, void *value, void (*freecb)(void*));
-
extern void *afb_session_get_cookie(struct afb_session *session, const void *key);
+extern void *afb_session_cookie(struct afb_session *session, const void *key, void *(*makecb)(void *closure), void (*freecb)(void *item), void *closure, int replace);
extern int afb_session_set_cookie(struct afb_session *session, const void *key, void *value, void (*freecb)(void*));