aboutsummaryrefslogtreecommitdiff
path: root/command.c
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-03-16 21:42:24 +0100
committertomsmeding <tom.smeding@gmail.com>2017-03-16 21:42:24 +0100
commit9d21406d68ebdce18110431fb24c9963dcc44373 (patch)
tree954a0fdc48ef473f8c1faf7177c064c33d8ab4a0 /command.c
parent047e1828901b5b08cd538a7b11c0de2149606797 (diff)
Send new messages to every fd of user
Diffstat (limited to 'command.c')
-rw-r--r--command.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/command.c b/command.c
index 0f2cd06..bf6c29d 100644
--- a/command.c
+++ b/command.c
@@ -212,10 +212,13 @@ static bool cmd_send(struct conn_data *data,const char *tag,const char **args){
struct db_user_list members=db_get_members(roomid);
for(i64 i=0;i<members.count;i++){
- int fd=userdata_online(members.list[i].id);
- if(fd!=-1&&fd!=data->fd){
- send_push(fd,"message",args[1]);
- // TODO: unregister and close users that aren't reachable anymore; maybe ping instead?
+ i64 nfds;
+ const int *fds=userdata_online(members.list[i].id,&nfds);
+ if(nfds<=0)continue;
+ for(i64 j=0;j<nfds;j++){
+ if(fds[j]!=data->fd){
+ send_push(fds[j],"message",args[1]);
+ }
}
}