send_custom_user_packet now returns -1 when friend is offline.

This commit is contained in:
irungentoo 2014-03-08 17:21:39 -05:00
parent 0e97836e01
commit 8d7ba013a5
2 changed files with 8 additions and 0 deletions

View File

@ -1662,6 +1662,12 @@ int custom_user_packet_registerhandler(Messenger *m, int friendnumber, uint8_t b
int send_custom_user_packet(Messenger *m, int friendnumber, uint8_t *data, uint32_t length) int send_custom_user_packet(Messenger *m, int friendnumber, uint8_t *data, uint32_t length)
{ {
if (friend_not_valid(m, friendnumber))
return -1;
if (m->friendlist[friendnumber].status != FRIEND_ONLINE)
return -1;
IP_Port ip_port = get_friend_ipport(m, friendnumber); IP_Port ip_port = get_friend_ipport(m, friendnumber);
if (ip_port.port == 0) if (ip_port.port == 0)
@ -2026,6 +2032,7 @@ void do_friends(Messenger *m)
break; break;
group_newpeer(m->chats[groupnum], data + crypto_box_PUBLICKEYBYTES); group_newpeer(m->chats[groupnum], data + crypto_box_PUBLICKEYBYTES);
/* This is just there to speedup joining. */
chat_bootstrap(m->chats[groupnum], get_friend_ipport(m, i), data + crypto_box_PUBLICKEYBYTES); chat_bootstrap(m->chats[groupnum], get_friend_ipport(m, i), data + crypto_box_PUBLICKEYBYTES);
break; break;
} }

View File

@ -528,6 +528,7 @@ int send_onion_data(Onion_Client *onion_c, int friend_num, uint8_t *data, uint32
continue; continue;
++num_nodes; ++num_nodes;
if (list_nodes[i].is_stored) { if (list_nodes[i].is_stored) {
if (random_path(onion_c->dht, &onion_c->friends_list[friend_num].onion_paths, ~0, &path[num_good]) == -1) if (random_path(onion_c->dht, &onion_c->friends_list[friend_num].onion_paths, ~0, &path[num_good]) == -1)
continue; continue;