summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/afb-ws-json.c7
-rw-r--r--src/session.c30
-rw-r--r--src/session.h16
3 files changed, 26 insertions, 27 deletions
diff --git a/src/afb-ws-json.c b/src/afb-ws-json.c
index e1347f14..4393d093 100644
--- a/src/afb-ws-json.c
+++ b/src/afb-ws-json.c
@@ -54,7 +54,7 @@ struct afb_ws_json
static void aws_send_event(struct afb_ws_json *ws, const char *event, struct json_object *object);
-static const struct afb_event_sender_itf event_sender_itf = {
+static const struct afb_event_listener_itf event_listener_itf = {
.send = (void*)aws_send_event
};
@@ -84,7 +84,7 @@ struct afb_ws_json *afb_ws_json_create(int fd, struct AFB_clientCtx *context, vo
if (result->ws == NULL)
goto error4;
- if (0 > ctxClientEventSenderAdd(result->context, (struct afb_event_sender){ .itf = &event_sender_itf, .closure = result }))
+ if (0 > ctxClientEventListenerAdd(result->context, (struct afb_event_listener){ .itf = &event_listener_itf, .closure = result }))
goto error5;
return result;
@@ -104,7 +104,7 @@ error:
static void aws_on_hangup(struct afb_ws_json *ws)
{
- ctxClientEventSenderRemove(ws->context, (struct afb_event_sender){ .itf = &event_sender_itf, .closure = ws });
+ ctxClientEventListenerRemove(ws->context, (struct afb_event_listener){ .itf = &event_listener_itf, .closure = ws });
afb_ws_destroy(ws->ws);
json_tokener_free(ws->tokener);
if (ws->cleanup != NULL)
@@ -160,7 +160,6 @@ static const struct afb_req_itf wsreq_itf = {
.session_close = (void*)wsreq_session_close,
.context_get = (void*)afb_context_get,
.context_set = (void*)afb_context_set
-
};
static int aws_wsreq_parse(struct afb_wsreq *r, char *text, size_t size)
diff --git a/src/session.c b/src/session.c
index d4abde65..ae44f793 100644
--- a/src/session.c
+++ b/src/session.c
@@ -292,18 +292,18 @@ void ctxTokenNew (struct AFB_clientCtx *clientCtx)
clientCtx->expiration = NOW + sessions.timeout;
}
-struct afb_event_sender_list
+struct afb_event_listener_list
{
- struct afb_event_sender_list *next;
- struct afb_event_sender sender;
+ struct afb_event_listener_list *next;
+ struct afb_event_listener listener;
int refcount;
};
-int ctxClientEventSenderAdd(struct AFB_clientCtx *clientCtx, struct afb_event_sender sender)
+int ctxClientEventListenerAdd(struct AFB_clientCtx *clientCtx, struct afb_event_listener listener)
{
- struct afb_event_sender_list *iter, **prv;
+ struct afb_event_listener_list *iter, **prv;
- prv = &clientCtx->senders;
+ prv = &clientCtx->listeners;
for (;;) {
iter = *prv;
if (iter == NULL) {
@@ -312,12 +312,12 @@ int ctxClientEventSenderAdd(struct AFB_clientCtx *clientCtx, struct afb_event_se
errno = ENOMEM;
return -1;
}
- iter->sender = sender;
+ iter->listener = listener;
iter->refcount = 1;
*prv = iter;
return 0;
}
- if (iter->sender.itf == sender.itf && iter->sender.closure == sender.closure) {
+ if (iter->listener.itf == listener.itf && iter->listener.closure == listener.closure) {
iter->refcount++;
return 0;
}
@@ -325,16 +325,16 @@ int ctxClientEventSenderAdd(struct AFB_clientCtx *clientCtx, struct afb_event_se
}
}
-void ctxClientEventSenderRemove(struct AFB_clientCtx *clientCtx, struct afb_event_sender sender)
+void ctxClientEventListenerRemove(struct AFB_clientCtx *clientCtx, struct afb_event_listener listener)
{
- struct afb_event_sender_list *iter, **prv;
+ struct afb_event_listener_list *iter, **prv;
- prv = &clientCtx->senders;
+ prv = &clientCtx->listeners;
for (;;) {
iter = *prv;
if (iter == NULL)
return;
- if (iter->sender.itf == sender.itf && iter->sender.closure == sender.closure) {
+ if (iter->listener.itf == listener.itf && iter->listener.closure == listener.closure) {
if (!--iter->refcount) {
*prv = iter->next;
free(iter);
@@ -347,13 +347,13 @@ void ctxClientEventSenderRemove(struct AFB_clientCtx *clientCtx, struct afb_even
static int send(struct AFB_clientCtx *clientCtx, const char *event, struct json_object *object)
{
- struct afb_event_sender_list *iter;
+ struct afb_event_listener_list *iter;
int result;
result = 0;
- iter = clientCtx->senders;
+ iter = clientCtx->listeners;
while (iter != NULL) {
- iter->sender.itf->send(iter->sender.closure, event, json_object_get(object));
+ iter->listener.itf->send(iter->listener.closure, event, json_object_get(object));
result++;
iter = iter->next;
}
diff --git a/src/session.h b/src/session.h
index 7930bdb3..f6d67fe6 100644
--- a/src/session.h
+++ b/src/session.h
@@ -28,28 +28,28 @@ struct afb_context
extern void *afb_context_get(struct afb_context *actx);
extern void afb_context_set(struct afb_context *actx, void *context, void (*free_context)(void*));
-struct afb_event_sender_itf
+struct afb_event_listener_itf
{
void (*send)(void *closure, const char *event, struct json_object *object);
};
-struct afb_event_sender
+struct afb_event_listener
{
- const struct afb_event_sender_itf *itf;
+ const struct afb_event_listener_itf *itf;
void *closure;
};
-struct afb_event_sender_list;
+struct afb_event_listener_list;
struct AFB_clientCtx
{
- time_t expiration; // expiration time of the token
int created;
unsigned refcount;
+ time_t expiration; // expiration time of the token
struct afb_context *contexts;
char uuid[37]; // long term authentication of remote client
char token[37]; // short term authentication of remote client
- struct afb_event_sender_list *senders;
+ struct afb_event_listener_list *listeners;
};
extern void ctxStoreInit (int max_session_count, int timeout, const char *initok, int context_count);
@@ -59,8 +59,8 @@ extern struct AFB_clientCtx *ctxClientGet(struct AFB_clientCtx *clientCtx);
extern void ctxClientPut(struct AFB_clientCtx *clientCtx);
extern void ctxClientClose (struct AFB_clientCtx *clientCtx);
-extern int ctxClientEventSenderAdd(struct AFB_clientCtx *clientCtx, struct afb_event_sender sender);
-extern void ctxClientEventSenderRemove(struct AFB_clientCtx *clientCtx, struct afb_event_sender sender);
+extern int ctxClientEventListenerAdd(struct AFB_clientCtx *clientCtx, struct afb_event_listener listener);
+extern void ctxClientEventListenerRemove(struct AFB_clientCtx *clientCtx, struct afb_event_listener listener);
extern int ctxClientEventSend(struct AFB_clientCtx *clientCtx, const char *event, struct json_object *object);
extern int ctxTokenCheck (struct AFB_clientCtx *clientCtx, const char *token);