notify toxic as if we are toxcore
This commit is contained in:
parent
e858f23fc1
commit
f8816d5c53
20
ngc_hs1.cpp
20
ngc_hs1.cpp
@ -351,6 +351,13 @@ void NGC_HS1_record_own_message(
|
|||||||
assert(ngc_hs1_ctx->history.count(g_id));
|
assert(ngc_hs1_ctx->history.count(g_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NGC_HS1_register_callback_group_message(NGC_EXT_CTX* ngc_ext_ctx, NGC_HS1_group_message_cb* callback) {
|
||||||
|
assert(ngc_ext_ctx);
|
||||||
|
assert(ngc_ext_ctx->ngc_hs1_ctx);
|
||||||
|
|
||||||
|
ngc_ext_ctx->ngc_hs1_ctx->cb_group_message = callback;
|
||||||
|
}
|
||||||
|
|
||||||
// record others msg
|
// record others msg
|
||||||
void NGC_HS1_record_message(
|
void NGC_HS1_record_message(
|
||||||
const Tox *tox,
|
const Tox *tox,
|
||||||
@ -566,6 +573,19 @@ void _handle_HS1_ft_recv_data(
|
|||||||
peer.pending.erase(transfer.msg_id);
|
peer.pending.erase(transfer.msg_id);
|
||||||
peer.append(transfer.msg_id, static_cast<Tox_Message_Type>(transfer.recv_buffer.front()), std::string(reinterpret_cast<const char*>(transfer.recv_buffer.data()+1)));
|
peer.append(transfer.msg_id, static_cast<Tox_Message_Type>(transfer.recv_buffer.front()), std::string(reinterpret_cast<const char*>(transfer.recv_buffer.data()+1)));
|
||||||
|
|
||||||
|
assert(ngc_ext_ctx->ngc_hs1_ctx->cb_group_message);
|
||||||
|
// we dont notify if we dont know the peer id. this kinda breaks some stuff
|
||||||
|
if (peer.id.has_value()) {
|
||||||
|
ngc_ext_ctx->ngc_hs1_ctx->cb_group_message(
|
||||||
|
tox,
|
||||||
|
group_number, peer.id.value(),
|
||||||
|
static_cast<Tox_Message_Type>(transfer.recv_buffer.front()),
|
||||||
|
transfer.recv_buffer.data()+1,
|
||||||
|
data_size-1,
|
||||||
|
transfer.msg_id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
group.transfers.erase(std::make_pair(peer_number, transfer_id));
|
group.transfers.erase(std::make_pair(peer_number, transfer_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
17
ngc_hs1.h
17
ngc_hs1.h
@ -80,11 +80,18 @@ void NGC_HS1_record_own_message(
|
|||||||
|
|
||||||
// ========== receive message ==========
|
// ========== receive message ==========
|
||||||
|
|
||||||
// !!! no shim, whould require global state !!!
|
typedef void NGC_HS1_group_message_cb(
|
||||||
// shim (same interface)
|
Tox *tox,
|
||||||
//typedef void tox_group_message_cb(Tox *tox, uint32_t group_number, uint32_t peer_id, Tox_Message_Type type,
|
uint32_t group_number,
|
||||||
//const uint8_t *message, size_t length, uint32_t message_id, void *user_data);
|
uint32_t peer_id,
|
||||||
//void NGC_HS1_callback_group_message(Tox *tox, NGC_HS1* ngc_hs1_ctx, tox_group_message_cb *callback);
|
Tox_Message_Type type,
|
||||||
|
const uint8_t *message,
|
||||||
|
size_t length,
|
||||||
|
uint32_t message_id
|
||||||
|
);
|
||||||
|
|
||||||
|
// callback for when history sync has a new message
|
||||||
|
void NGC_HS1_register_callback_group_message(NGC_EXT_CTX* ngc_ext_ctx, NGC_HS1_group_message_cb* callback);
|
||||||
|
|
||||||
// record others msg
|
// record others msg
|
||||||
void NGC_HS1_record_message(
|
void NGC_HS1_record_message(
|
||||||
|
@ -17,7 +17,7 @@ struct NGC_HS1 {
|
|||||||
|
|
||||||
// callbacks
|
// callbacks
|
||||||
//tox_group_message_cb* client_tox_msg_callback;
|
//tox_group_message_cb* client_tox_msg_callback;
|
||||||
|
NGC_HS1_group_message_cb* cb_group_message {nullptr};
|
||||||
|
|
||||||
// key - key - key - value store
|
// key - key - key - value store
|
||||||
// group pubkey - peer pubkey - msg_id - message(type + text)
|
// group pubkey - peer pubkey - msg_id - message(type + text)
|
||||||
|
Reference in New Issue
Block a user