aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-03-16 21:06:11 +0100
committertomsmeding <tom.smeding@gmail.com>2017-03-16 21:06:57 +0100
commit047e1828901b5b08cd538a7b11c0de2149606797 (patch)
tree9249612fe9bb88bf3063733744a6c02c391e5739 /main.c
parenta441b302c2c11c291df60fe642ec0d51646218dd (diff)
Basic message sending
TODO: broadcast to all online fd's of a user? TODO: close users that aren't reachable in a broadcast?
Diffstat (limited to 'main.c')
-rw-r--r--main.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/main.c b/main.c
index cfedf93..557dc77 100644
--- a/main.c
+++ b/main.c
@@ -10,6 +10,7 @@
#include "conn_data.h"
#include "db.h"
#include "runloop.h"
+#include "user_data.h"
#define PORT (29536) // python: int("msg",36)
@@ -50,6 +51,7 @@ static void delete_conn_data(int fd){
struct hash_item *item=conn_hash[fd%CONN_HASH_SIZE];
assert(item);
if(item->cd.fd==fd){
+ if(item->cd.userid!=-1)userdata_unregister(item->cd.userid,fd);
conn_hash[fd%CONN_HASH_SIZE]=item->next;
conn_data_nullify(&item->cd);
free(item);
@@ -62,6 +64,7 @@ static void delete_conn_data(int fd){
}
assert(parent);
assert(item);
+ if(item->cd.userid!=-1)userdata_unregister(item->cd.userid,fd);
conn_data_nullify(&item->cd);
parent->next=item->next;
free(item);