tox-rs / tox

toxcore implementation in Rust
GNU General Public License v3.0
448 stars 32 forks source link

[Question] Can I send friend request with a message? #432

Open FrontMage opened 4 years ago

FrontMage commented 4 years ago

I looked up the documentation, the add_friend accepts only one param which is the public key of the friend, but the C binding lib can add friend with a message, so I wonder if there is a way to achieve this.

I noticed that there is a FriendRequests struct, but it seems never used in the code.

Thanks for the help!

kurnevsky commented 4 years ago

Currently we have only low level api. add_friend means we add it to friends list only but don't send friend request. Therefore it doesn't contain message parameter.

FrontMage commented 4 years ago

Currently we have only low level api. add_friend means we add it to friends list only but don't send friend request. Therefore it doesn't contain message parameter.

Thanks for the reply. I wonder if I can use something like send_lossless to fire a request with a message, I tried to modify the echo.rs example, but it turns out I needed friends to be accepted to use send_lossless. Then I dived into the code, found out that the dht server maintains all close by node information, but I can't seem to connect to a friend node no matter how. The code clearly says it can punch UDP holes if there are no other relays, I kind got stuck here.

Can you make an example about how to send friend request? Much appreciated!