diff options
Diffstat (limited to 'toxcore/group_chats.c')
-rw-r--r-- | toxcore/group_chats.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/toxcore/group_chats.c b/toxcore/group_chats.c index 85057e9f..ba7e0750 100644 --- a/toxcore/group_chats.c +++ b/toxcore/group_chats.c | |||
@@ -213,6 +213,7 @@ static int addpeer(Group_Chat *chat, uint8_t *client_id) | |||
213 | chat->group = temp; | 213 | chat->group = temp; |
214 | id_copy(chat->group[chat->numpeers].client_id, client_id); | 214 | id_copy(chat->group[chat->numpeers].client_id, client_id); |
215 | chat->group[chat->numpeers].last_recv = unix_time(); | 215 | chat->group[chat->numpeers].last_recv = unix_time(); |
216 | chat->group[chat->numpeers].last_recv_msgping = unix_time(); | ||
216 | ++chat->numpeers; | 217 | ++chat->numpeers; |
217 | return (chat->numpeers - 1); | 218 | return (chat->numpeers - 1); |
218 | } | 219 | } |
@@ -576,11 +577,23 @@ static void ping_group(Group_Chat *chat) | |||
576 | } | 577 | } |
577 | } | 578 | } |
578 | 579 | ||
580 | static void del_dead_peers(Group_Chat *chat) | ||
581 | { | ||
582 | uint32_t i; | ||
583 | for (i = 0; i < chat->numpeers; ++i) { | ||
584 | if (is_timeout(chat->group[i].last_recv_msgping, GROUP_PING_INTERVAL*2)) { | ||
585 | delpeer(chat, chat->group[i].client_id); | ||
586 | } | ||
587 | } | ||
588 | } | ||
589 | |||
579 | void do_groupchat(Group_Chat *chat) | 590 | void do_groupchat(Group_Chat *chat) |
580 | { | 591 | { |
581 | unix_time_update(); | 592 | unix_time_update(); |
582 | ping_close(chat); | 593 | ping_close(chat); |
583 | ping_group(chat); | 594 | ping_group(chat); |
595 | /* TODO: Maybe run this less? */ | ||
596 | del_dead_peers(chat); | ||
584 | } | 597 | } |
585 | 598 | ||
586 | void kill_groupchat(Group_Chat *chat) | 599 | void kill_groupchat(Group_Chat *chat) |