|
|
|
@ -405,17 +405,18 @@ int chat_invite_candidate_nodes(struct UTUN_INSTANCE* inst, uint64_t channel_id, |
|
|
|
void chat_invite_candidates_trampoline(void* arg) { |
|
|
|
void chat_invite_candidates_trampoline(void* arg) { |
|
|
|
struct chat_invite_cand_req* req = (struct chat_invite_cand_req*)arg; |
|
|
|
struct chat_invite_cand_req* req = (struct chat_invite_cand_req*)arg; |
|
|
|
if (!req) return; |
|
|
|
if (!req) return; |
|
|
|
|
|
|
|
struct UTUN_INSTANCE* inst = req->inst; |
|
|
|
char ch_id[64]; |
|
|
|
char ch_id[64]; |
|
|
|
strncpy(ch_id, req->ch_id, sizeof(ch_id) - 1); |
|
|
|
strncpy(ch_id, req->ch_id, sizeof(ch_id) - 1); |
|
|
|
ch_id[sizeof(ch_id) - 1] = '\0'; |
|
|
|
ch_id[sizeof(ch_id) - 1] = '\0'; |
|
|
|
u_free(arg); |
|
|
|
u_free(arg); |
|
|
|
if (!CC(req->inst) || !CC(req->inst)->initialized) { DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "invite_build: candidates — not initialized"); return; } |
|
|
|
if (!CC(inst) || !CC(inst)->initialized) { DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "invite_build: candidates — not initialized"); return; } |
|
|
|
|
|
|
|
|
|
|
|
uint64_t channel_id = strtoull(ch_id, NULL, 10); |
|
|
|
uint64_t channel_id = strtoull(ch_id, NULL, 10); |
|
|
|
uint64_t auto_id = 0; |
|
|
|
uint64_t auto_id = 0; |
|
|
|
chat_invite_best_node(req->inst, channel_id, &auto_id); |
|
|
|
chat_invite_best_node(inst, channel_id, &auto_id); |
|
|
|
uint64_t ids[INVITE_ADDR_MAX]; |
|
|
|
uint64_t ids[INVITE_ADDR_MAX]; |
|
|
|
int cnt = chat_invite_candidate_nodes(req->inst, channel_id, ids, INVITE_ADDR_MAX); |
|
|
|
int cnt = chat_invite_candidate_nodes(inst, channel_id, ids, INVITE_ADDR_MAX); |
|
|
|
if (cnt < 0) cnt = 0; |
|
|
|
if (cnt < 0) cnt = 0; |
|
|
|
|
|
|
|
|
|
|
|
size_t ch_len = strlen(ch_id); |
|
|
|
size_t ch_len = strlen(ch_id); |
|
|
|
@ -428,7 +429,7 @@ void chat_invite_candidates_trampoline(void* arg) { |
|
|
|
uint16_t u16 = (uint16_t)cnt; |
|
|
|
uint16_t u16 = (uint16_t)cnt; |
|
|
|
memcpy(evt + 1 + ch_len + 8, &u16, 2); |
|
|
|
memcpy(evt + 1 + ch_len + 8, &u16, 2); |
|
|
|
for (int i = 0; i < cnt; i++) memcpy(evt + 1 + ch_len + 8 + 2 + i * 8, &ids[i], 8); |
|
|
|
for (int i = 0; i < cnt; i++) memcpy(evt + 1 + ch_len + 8 + 2 + i * 8, &ids[i], 8); |
|
|
|
chat_event_post(req->inst, CHAT_EVT_INVITE_CANDIDATES, evt, (int)evt_sz); |
|
|
|
chat_event_post(inst, CHAT_EVT_INVITE_CANDIDATES, evt, (int)evt_sz); |
|
|
|
u_free(evt); |
|
|
|
u_free(evt); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|