aboutsummaryrefslogtreecommitdiff
path: root/event.h
blob: 0254702d69adc94f5182c602db7751412343a24f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#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 replyid;
	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,i64 replyid);
void event_emit_online(i64 timestamp,const char *user,i64 numonline);
void event_emit_join(i64 timestamp,const char *user,const char *room);