aboutsummaryrefslogtreecommitdiff
path: root/event.h
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-05-08 22:06:47 +0200
committertomsmeding <tom.smeding@gmail.com>2017-05-08 22:08:56 +0200
commita7a0ce278e661bf5d3f2b47556d8c30469d2bd6c (patch)
treedef6c7b56df0b21351c4f1b0766163426ee47649 /event.h
parent886fc77026a2a805e5d166b2f87bd24720ad9ea4 (diff)
server: Add event system
Diffstat (limited to 'event.h')
-rw-r--r--event.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/event.h b/event.h
new file mode 100644
index 0000000..638cd20
--- /dev/null
+++ b/event.h
@@ -0,0 +1,31 @@
+#pragma once
+
+#include "global.h"
+
+
+enum event_type{
+ EVENT_MESSAGE, // message, user, room
+ EVENT_ONLINE, // user, num
+ EVENT_JOIN, // user, room
+};
+
+struct event_item{
+ enum event_type type;
+ i64 timestamp; // always set
+ char *message,*user,*room;
+ i64 num;
+};
+
+typedef void event_callback_t(const struct event_item *event);
+
+
+void event_register(event_callback_t *cb);
+void event_unregister(event_callback_t *cb);
+
+struct event_item* event_item_alloc(void);
+void event_item_free(struct event_item *event);
+
+void event_emit(const struct event_item *event);
+void event_emit_message(i64 timestamp,const char *message,const char *user,const char *room);
+void event_emit_online(i64 timestamp,const char *user,i64 numonline);
+void event_emit_join(i64 timestamp,const char *user,const char *room);