fix message reading and writing

This commit is contained in:
Green Sky 2023-01-12 03:24:15 +01:00
parent f8816d5c53
commit e974522a38
No known key found for this signature in database

View File

@ -581,7 +581,7 @@ void _handle_HS1_ft_recv_data(
group_number, peer.id.value(),
static_cast<Tox_Message_Type>(transfer.recv_buffer.front()),
transfer.recv_buffer.data()+1,
data_size-1,
transfer.recv_buffer.size()-2,
transfer.msg_id
);
}
@ -618,14 +618,15 @@ void _handle_HS1_ft_send_data(
// get msg
const auto& message = group.peers.at(msg_peer).dict.at(msg_id);
size_t i = 0;
size_t data_i = 0;
if (data_offset == 0) {
// serl type
data[i++] = message.type;
data[data_i++] = message.type;
data_offset += 1;
}
for (; i < data_size; i++) {
data[i] = message.text.at((data_offset+i)-1);
for (size_t i = 0; data_i < data_size; i++, data_i++) {
data[data_i] = message.text.at(data_offset+i-1);
}
if (data_offset + data_size == 1 + message.text.size()) {